All pastes #556604 Raw Edit

omen

public text v1 · immutable
·published 2007-06-10 17:47 UTC
rendered paste body
//JUNK EMPIRES FARM

AddCSLuaFile( "shared.lua" )
include( 'shared.lua' )

function ENT:SpawnFunction( ply, tr )

	if ( !tr.Hit ) then return end
	
	local SpawnPos = tr.HitPos + tr.HitNormal * 16
	
	local ent = ents.Create( "farm" )
		ent:SetPos( SpawnPos )
	ent:Spawn()
	ent:Activate()
	
	return ent
	
end

function ENT:Initialize()
	
	//the mine
	self.Entity:SetModel( "models/props_junk/garbage_takeoutcarton001a.mdl" )
	self.Entity:PhysicsInit( SOLID_VPHYSICS )
	self.Entity:SetMoveType( MOVETYPE_VPHYSICS )
	self.Entity:SetSolid( SOLID_VPHYSICS ) 
	self.Entity:SetColor( 255,255,255,255 )

	local phys = self.Entity:GetPhysicsObject()
	if (phys:IsValid()) then
		phys:EnableMotion(false) //Don't want it rolling around everywhere
	end
	
	self.claimed = false
	self.claimebel = false
	self.claimebelby = "nothing"
	self.Overlord = "nothing"
	
end

function ENT:Use(ply)
if (self.claimebel) then
	--if(self.claimebelby == ply) then
			inSupply = true

	end
		if(inSupply) then
		if(!self.claimed) then
		self.Entity:SetColor(ply:GetColor())
		ply:SetNWInt(ply:Nick() .. "_farms", ply:GetNWInt(ply:Nick() .. "_farms") + 1) 
		self.claimed = true
		self.Overlord = ply
	end
	end
		if(!inSupply) then
		ply:ChatPrint("Can't take this you dont have a city close.")
		return
	end
	inSupply = false
end


function ENT:GetOverlord()
	return self.Overlord
end

function ENT:RemoveControl()
	if(self.Overlord != "nothing") then
		self.Overlord:SetNWInt(self.Overlord:Nick() .. "_farms", self.Overlord:GetNWInt(self.Overlord:Nick() .. "_farms") - 1)
		self.claimed = false
		self.Overlord = nil
		self.Entity:SetColor( 255,255,255,255 )
	end
end