I'm using a flamethrower base for my other swep.
Everything works fine currently except for an error that doesn't seem to affect anything but it's annoying as heck.
attempt to call a nil value
If I remove this code in my Swep lua it goes away:
[lua]
local trace = self.Owner:GetEyeTrace()
local flamefx = EffectData()
flamefx:SetOrigin(trace.HitPos)
flamefx:SetStart(self.Owner:GetShootPos())
flamefx:SetAttachment(1)
flamefx:SetEntity(self.Weapon)
util.Effect("swep_flamethrower_flame",flamefx,true,true)[/lua]
So it probably has something to do with the particles.
Here's the flamethrower particle script:
[lua]function EFFECT:Init( data )
local HitPos = data:GetOrigin()
local Weapon = data:GetEntity()
local Attachment = data:GetAttachment()
local StartPos = self:GetTracerShootPos( self.Position, Weapon, Attachment )
if Weapon:IsValid() then
local emitter = ParticleEmitter(StartPos)
for i=0, 8 do
local particle = emitter:Add( "effects/muzzleflash" .. math.random(2,3) .. "", StartPos )
if (particle) then
particle:SetVelocity( ((HitPos - StartPos):GetNormal() * math.random(1720,1820)) + (VectorRand() * math.random(142,172)) )
particle:SetLifeTime( 0 )
particle:SetDieTime( 0.52 )
particle:SetStartAlpha( math.random(82,112) )
particle:SetEndAlpha( 0 )
particle:SetStartSize( math.random(4,6) )
particle:SetEndSize( math.random(32,52) )
particle:SetRoll( math.Rand(-360, 360) )
particle:SetRollDelta( math.Rand(-7.2, 7.2) )
particle:SetAirResistance( math.random(128, 256) )
particle:SetCollide( true )
particle:SetGravity( Vector( 0, 0, 64 ) )
end
end
emitter:Finish()
end
end[/lua]
Anyone has any idea what's wrong?
Still waiting.
[lua]local StartPos = self:GetTracerShootPos( self.Position, Weapon, Attachment ) [/lua]
Is self.Position valid? Shouldn't you use data:GetStart()?
Sorry, you need to Log In to post a reply to this thread.