I need help with this code I'm trying to build. I basically want it to pretend to grind up a t's body for some equipment, I know the timer function there is screwy but I don't need it to be messed with, what I need is a way to test if a body belonged to a T before I let them grind it up. After you've helped me with that you can critique the crap out of the rest of the code.
[code]
function SWEP:PrimaryAttack()
if not self:CanPrimaryAttack() then return end
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
local tracedata = {}
tracedata.start = self.Owner:GetShootPos()
tracedata.endpos = self.Owner:GetShootPos() + (self.Owner:GetAimVector() * 100)
tracedata.filter = self.Owner
tracedata.mins = Vector(1,1,1) * -10
tracedata.maxs = Vector(1,1,1) * 10
tracedata.mask = MASK_SHOT_HULL
local tr = util.TraceHull( tracedata )
local ply = self.Owner
if IsValid(tr.Entity) then
--I need some way for this line to test if the ragdoll is a t's body? does anyone know how I could do that?
if tr.Entity.player_ragdoll then
timer.Simple(0.1, function()
ply:Freeze(true)
ply:SetColor(Color(255,0,0,255))
end)
self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
timer.Create("GivePlyHealth_"..self.Owner:UniqueID(),0.5,6,function() self.Owner:SetHealth(self.Owner:Health()) end)
timer.Simple(3.1, function()
if(ply:Alive()) then
ply:Freeze(false)
ply:SetColor(Color(255,255,255,255))
tr.Entity:Remove()
local thingy = ents.Create( "weapon_radiation" )
thingy:SetPos( ent:GetPos() )
thingy:Spawn()
self:Remove()
end
end )
self.Owner:EmitSound("sound/minigun/spinup.wav")
end
end
self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
end
[/code]
Look at the ragdoll code and how it displays the role
Where is that?
From a quick look in terrortown/gamemode/corpse.lua
[CODE]
// rag.was_role gets set to the players role when they die.
local role = rag.was_role
if role == ROLE_TRAITOR then
//Traitor corpse
elseif role == ROLE_DETECTIVE then
//Detective corpse
else
//Innocent corpse
end
[/CODE]
rag, as its used in that example (rag.was_role), is the corpse entity.
Hope that helps.
Sorry, you need to Log In to post a reply to this thread.