All pastes #483185 Raw Edit

Someone

public text v1 · immutable
·published 2007-05-11 16:28 UTC
rendered paste body
SWEP.Author			= "Demivion"
SWEP.Contact		= ""
SWEP.Purpose		= ""
SWEP.Instructions	= "Left click to select an NPC, right click to move the NPC"

SWEP.Spawnable			= true
SWEP.AdminSpawnable		= true

SWEP.ViewModel			= "models/weapons/v_pistol.mdl"
SWEP.WorldModel			= "models/weapons/w_pistol.mdl"

SWEP.Primary.ClipSize		= -1
SWEP.Primary.DefaultClip	= -1
SWEP.Primary.Automatic		= false
SWEP.Primary.Ammo			= "none"

SWEP.Secondary.ClipSize		= -1
SWEP.Secondary.DefaultClip	= -1
SWEP.Secondary.Automatic	= false
SWEP.Secondary.Ammo			= "none"
self.HasNPC = false
if (SERVER) then
	AddCSLuaFile("shared.lua")
end

function SWEP:Reload()
end
function SWEP:Think()
end

function SWEP:PrimaryAttack()	
local tr = {}
tr.start=self.Owner:GetShootPos() -- self.Owner is the player holding the swep
tr.endpos=self.Owner:GetAimVector()*2000000 -- the players aimvector =)
tr.filter=self.Owner
local Trace = util.TraceLine(tr)
if Trace.Entity && Trace.Entity:IsNPC() then
if self.HasNPC == false then
 self.NPC = Trace.Entity
 self.HasNPC = true
 else 
  self.HasNPC = false
  
  end
 end
end

function SWEP:SecondaryAttack()
local tr = {}
tr.start=self.Owner:GetShootPos() -- self.Owner is the player holding the swep
tr.endpos=self.Owner:GetAimVector()*2000000 -- the players aimvector =)
tr.filter=self.Owner
local Trace = util.TraceLine(tr)
if Trace.Hit then
 local HP = Trace.HitPos
 if self.HasNPC == true
  then
 self.NPC:SetLastPosition( HP )
 self.NPC:SetSchedule( SCHED_FORCED_GO_RUN ) 
 else
 self.Owner:PrintMessage(HUD_PRINTTALK, "You have no NPC selected!")
		end
	end
end