I have a weapon problem for TTT mode, I have a "weapon_ttt_ied" addon on the server, it usually works without a problem, but once every few days I have 18k logs for no reason:
[ERROR] addons/ttt_ied/lua/autorun/sh_ied.lua:45: Tried to use a NULL entity!
1. GetPos - [C]:-1
2. fn - addons/ttt_ied/lua/autorun/sh_ied.lua:45
3. unknown - addons/ulx_ulib_v2.63/lua/ulib/shared/hook.lua:109
Here I am sending a file to download, could anyone help me solve this problem?
sh_ied.lua
did you make this yourself?
are there multiple people using this at the same time?
try changing this function
function ENT:doIEDExplosionThink( ply, snd, wep, delay )
local delay = delay or CurTime() + 3.2
self.detonating = true
self.timeUntilDet = delay
if SERVER then
hook.Add( "Think", "IEDExplosion"..self:EntIndex(), function()
if !self or self and !self:IsValid() then return end--let's make sufe the entity is not NULL before we proceed
if CurTime() > delay then
self.timeUntilDet = delay - CurTime()
if !self:IsPlayer() or self:Alive() then
self.detonating = false
util.BlastDamage( Entity( 0 ), ply and ply or Entity( 0 ), self:GetPos(), 800, 200 )
local effect = EffectData()
effect:SetStart( self:GetPos() )
effect:SetOrigin( self:GetPos() )
effect:SetScale( 400 )
effect:SetRadius( 400 )
effect:SetMagnitude(220 )
effect:SetNormal( self:GetUp() )
util.Effect("Explosion", effect, true, true)
hook.Remove( "Think", "IEDExplosion"..self:EntIndex() )
ply:setIEDTarget( nil )
self:setIED( false )
else
hook.Remove( "Think", "IEDExplosion"..self:EntIndex() )
end
end
end)
end
end
Use IsValid(self). It checks if self is not nil and if it is valid.
Remember when using timers or hooks with asynchronous functions (functions that are not executed in the same frame), the entity could be removed in between. So always use IsValid checks in said functions.
Sorry, you need to Log In to post a reply to this thread.