• Jihad bomb problem.
    4 replies, posted
Every time I run my server, I see the error "attempt to index global 'self' <a nil value." [CODE] if (SERVER) then timer.Simple(2, function() self:Asplode() end ) self.Owner:EmitSound( "siege/jihad.wav" ) end --The asplode function function SWEP:Asplode() local k, v // Make an explosion at your position local ent = ents.Create( "env_explosion" ) ent:SetPos( self.Owner:GetPos() ) ent:SetOwner( self.Owner ) ent:Spawn() ent:SetKeyValue( "iMagnitude", "250" ) ent:Fire( "Explode", 0, 0 ) ent:EmitSound( "siege/big_explosion.wav", 500, 500 ) self.Owner:Kill( ) for k, v in pairs( player.GetAll( ) ) do v:ConCommand( "play siege/big_explosion.wav\n" ) end end /*--------------------------------------------------------- SecondaryAttack ---------------------------------------------------------*/ function SWEP:SecondaryAttack() self.Weapon:SetNextSecondaryFire( CurTime() + 1 ) local TauntSound = Sound( "vo/npc/male01/overhere01.wav" ) self.Weapon:EmitSound( TauntSound ) // The rest is only done on the server if (!SERVER) then return end self.Weapon:EmitSound( TauntSound ) end[/CODE] For the record this is a code my friend sent me. I didn't write any of this. I just need help trying to fix this. Any help? [editline]4th January 2013[/editline] Anyone please? Hate to bump but, I really need help.
Is this the portion of the code with the error in it? What line number does the error report specify?
Isn't this weapon for Garry's Mod 12? Also, we need a line number for the error.
[lua]if (SERVER) then timer.Simple(2, function() self:Asplode() end ) self.Owner:EmitSound( "siege/jihad.wav" ) //Here's the line with the error. end [/lua] That bit needs to be in a function. Though I don't fully understand why 'cause I'm not very experienced with Lua, I do know that "self" does not work outside of a function.
That should be in SWEP:PrimaryAttack()
Sorry, you need to Log In to post a reply to this thread.