Hello, good day to you.
I am having a problem with an error that my weapon throws when it ignites the player.
It successfully ignites the player but it also throws an error that it cannot call the method 'Ignite'
Copy of code in question:
[CODE]
function SWEP:SecondaryAttack()
pos = self.Owner:GetShootPos()
ang = self.Owner:GetAimVector()
vm = self.Owner:GetViewModel()
if self:CanPrimaryAttack() and self.Owner:IsPlayer() then
self.Weapon:SendWeaponAnim( ACT_VM_IDLE )
if !self.Owner:KeyDown(IN_SPEED) and !self.Owner:KeyDown(IN_RELOAD) then
local stab = {}
stab.start = pos
stab.endpos = pos + (ang * 24)
stab.filter = self.Owner
stab.mins = Vector(-10,-5, 0)
stab.maxs = Vector(10, 5, 5)
local stabtrace = util.TraceHull(stab)
if stabtrace.Hit then
vm:SetSequence(vm:LookupSequence("stab"))
else
vm:SetSequence(vm:LookupSequence("stab_miss"))
end
timer.Create("cssstab", .33, 1 , function() if not IsValid(self) then return end
if IsValid(self.Owner) and IsValid(self.Weapon) then
if self.Owner:Alive() and self.Owner:GetActiveWeapon():GetClass() == self.Gun then
self:Stab() end
end
end)
self.Owner:SetAnimation( PLAYER_ATTACK1 )
self.Weapon:SetNextPrimaryFire(CurTime()+1/(self.Primary.RPM/60))
self.Weapon:SetNextSecondaryFire(CurTime()+1.25)
end
end
end
function SWEP:Stab()
pos2 = self.Owner:GetShootPos()
ang2 = self.Owner:GetAimVector()
damagedice = math.Rand(.85,1.25)
pain = 100 * damagedice
self.Owner:LagCompensation(true)
local stab2 = {}
stab2.start = pos2
stab2.endpos = pos2 + (ang2 * 24)
stab2.filter = self.Owner
stab2.mins = Vector(-10,-5, 0)
stab2.maxs = Vector(10, 5, 5)
local stabtrace2 = util.TraceHull(stab2)
if IsValid(self.Owner) and IsValid(self.Weapon) then
if self.Owner:Alive() then if self.Owner:GetActiveWeapon():GetClass() == self.Gun then
if stabtrace2.Hit then
targ = stabtrace2.Entity
if targ:IsPlayer() or targ:IsNPC() then
paininfo = DamageInfo()
paininfo:SetDamage(pain)
paininfo:SetDamageType(DMG_SLASH)
paininfo:SetAttacker(self.Owner)
paininfo:SetInflictor(self.Weapon)
local statues = ents.FindByClass("pdstatue")--FIND ALL PDSTATUES HERE
for k, v in pairs(statues) do --FOR ALL PDSTATUES FOUND DO:
local distance = self.Owner:GetPos():Distance(v:GetPos()) -- GET DISTANCE FOR THIS STATUE
if distance < 100 && self.Owner:IsValid() then --IF THE DISTANCE FOR THIS STATUE IS LESS THAN 100 UNITS
self.Owner:SetHealth(666)
self.Owner:Ignite(666) --WHERE WE IGNITE THE PLAYER
self.Owner:setGodlike(true)
end
end
paininfo:SetDamageForce(stabtrace2.Normal *75000)
if SERVER then targ:TakeDamageInfo(paininfo) end
self.Weapon:EmitSound(self.KnifeStab)//stab noise
else
self.Weapon:EmitSound(self.KnifeShink)//SHINK!
look = self.Owner:GetEyeTrace()
util.Decal("ManhackCut", look.HitPos + look.HitNormal, look.HitPos - look.HitNormal )
end
else
self.Weapon:EmitSound(self.Primary.Sound)
end
end end
end
self.Owner:LagCompensation(false)
end
[/CODE]
Copy of error:
[CODE]
[ERROR] addons/sacrificemod/lua/weapons/sacrifice_knife/shared.lua:231: attempt to call method 'Ignite' (a nil value)
1. Stab - addons/sacrificemod/lua/weapons/sacrifice_knife/shared.lua:231
2. unknown - addons/sacrificemod/lua/weapons/sacrifice_knife/shared.lua:186
Timer Failed! [cssstab][@addons/sacrificemod/lua/weapons/sacrifice_knife/shared.lua (line 183)]
[/CODE]
Just wondering why it gives the error so I I can make it go away.
Even so it still ignites the player with the same line of code?
And yes I'm using m9k as a base. -Don't judge me pls.
Sorry, you need to Log In to post a reply to this thread.