• Lua error causing TTT hang
    9 replies, posted
On my ttt server there is a lua error that happens sporadically with my jihad bomb the error is, [CODE]ERROR: Hook 'CheckTimers' Failed: .../terrortown/entities/weapons/weapon_ttt_jihad/shared.lua:98: Tried to use a NULL entity! Removing Hook 'CheckTimers' [/CODE] It only happens sometimes not all the time and when it does happen the round will not end. Im guessing that the line its pointing to has changed the line it points to is, [code]ent:SetPos( self.Owner:GetPos() ) [/code] I am stumped i do not know why this is causing an error. Here is the rest of the function that line is from [CODE]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 [/CODE]
The player holding the SWEP isn't valid when it's creating the explosion.
[QUOTE=Chessnut;38214220]The player holding the SWEP isn't valid when it's creating the explosion.[/QUOTE] can you explain what you mean a little more please?
You're trying to set the position of the explosion at the owner, but for some reason the owner isn't there. I'd bet he's dead, personally. I'd run it the script through something like this: [LUA] function SWEP:Asplode() local k, v if self.Owner:Alive() then // 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 end[/LUA]
[QUOTE=me-name-bob;38215188]You're trying to set the position of the explosion at the owner, but for some reason the owner isn't there. I'd bet he's dead, personally. I'd run it the script through something like this: [LUA] function SWEP:Asplode() local k, v if self.Owner:Alive() then // 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 end[/LUA][/QUOTE] i gave it a try now im just getting alive = nill value here the error [lua]ERROR: Hook 'CheckTimers' Failed: .../terrortown/entities/weapons/weapon_ttt_jihad/shared.lua:95: attempt to call method 'Alive' (a nil value) Removing Hook 'CheckTimers' [/lua]
what the hell. Think you can post the sweps full code?
[QUOTE=me-name-bob;38215675]what the hell. Think you can post the sweps full code?[/QUOTE] Sure thing [code]if SERVER then AddCSLuaFile( "shared.lua" ); resource.AddFile("sound/siege/jihad.wav"); resource.AddFile("sound/siege/big_explosion.wav"); end // Variables that are used on both client and server if CLIENT then SWEP.PrintName = "Jihad bomb" SWEP.Slot = 6 SWEP.Icon = "vgui/ttt/jihad_bender_icon" SWEP.EquipMenuData = { type = "item_weapon", name = "Jihad bomb", desc = "Sacrifice yourself for Allah.\nLeft Click to make yourself EXPLODE.\nRight click to taunt." }; end SWEP.Base = "weapon_tttbase" SWEP.Kind = WEAPON_EQUIP SWEP.CanBuy = {ROLE_TRAITOR} SWEP.WeaponID = AMMO_C4 SWEP.DrawCrosshair = false SWEP.Spawnable = true SWEP.AdminSpawnable = true // Spawnable in singleplayer or by server admins SWEP.ViewModel = "models/weapons/v_jb.mdl" SWEP.WorldModel = "models/weapons/w_jb.mdl" SWEP.Primary.ClipSize = -1 SWEP.Primary.DefaultClip = -1 SWEP.Primary.Automatic = false SWEP.Primary.Ammo = "none" SWEP.Primary.Delay = 3 SWEP.Secondary.ClipSize = -1 SWEP.Secondary.DefaultClip = -1 SWEP.Secondary.Automatic = false SWEP.Secondary.Ammo = "none" /*--------------------------------------------------------- Reload does nothing ---------------------------------------------------------*/ function SWEP:Reload() end function SWEP:Initialize() util.PrecacheSound("siege/big_explosion.wav") util.PrecacheSound("siege/jihad.wav") end /*--------------------------------------------------------- Think does nothing ---------------------------------------------------------*/ function SWEP:Think() end /*--------------------------------------------------------- PrimaryAttack ---------------------------------------------------------*/ function SWEP:PrimaryAttack() self.Weapon:SetNextPrimaryFire(CurTime() + 3) local effectdata = EffectData() effectdata:SetOrigin( self.Owner:GetPos() ) effectdata:SetNormal( self.Owner:GetPos() ) effectdata:SetMagnitude( 8 ) effectdata:SetScale( 1 ) effectdata:SetRadius( 16 ) util.Effect( "Sparks", effectdata ) self.BaseClass.ShootEffects( self ) // The rest is only done on the server if (SERVER) then timer.Simple(2, function() self:Asplode() end ) self.Owner:EmitSound( "siege/jihad.wav" ) end end --The asplode function function SWEP:Asplode() local k, v if self.Owner:Alive() then // 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 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] This isnt mine i used the jihad addon from 12 and i fixed all the errors caused by the update to 13 but this one.
Well, this is weird. I'm running it on my computer and the only thing giving me trouble is line 81, self.BaseClass.ShootEffects( self ) and that could be because i'm not working in ttt, i never play it myself. But other than that, it works fine. I'm at a loss. Where's you're hook, checktimers? Is that yours, or somewhere in the gamemode? edit: Hey pablo, if you know whats up, why dont you speak up instead of hiding behind your little box? jackass
Throw an IsValid(self.Owner) right before it does ent:SetPos ?
I have no clue where the hook checktimers is coming from, i have a feeling its from the ttt gamemode because when it happens the round doesn't end so im guessing that the error is caused by the person using the bomb being killed before it explodes.
Sorry, you need to Log In to post a reply to this thread.