[ERROR] Tried to use a NULL entity!

Can anyone help me with this annoying error …xd


[fibzeih|20|STEAM_0:1:48688711] Lua Error:

[ERROR] gamemodes/bhop/gamemode/sh_timer.lua:26: Tried to use a NULL entity!
  1. SetGravity - [C]:-1
   2. SetCheckStyle - gamemodes/bhop/gamemode/sh_timer.lua:26
    3. Function - gamemodes/bhop/gamemode/cl_timer.lua:324
     4. unknown - lua/includes/modules/usermessage.lua:87


Don’t know what “1. SetGravity - [C]:-1” means

sh_timer error line 26


local CSt = {}
function gtimer.SetCheckStyle(ply,st)
	CSt[ply] = st
	ply:SetGravity(1)
end

cl_timer error line 324


usermessage.Hook( "SetStyle", function(umsg)
	gtimer.style = umsg:ReadShort()
	gtimer.SetCheckStyle(LocalPlayer(),gtimer.style)
end)

Looks like it has a problem with the “ply:SetGravity(1)” which I don’t know why

in sh_timer check if ply is valid before applying table value and it gravity

Please, the user messages… Those have been deprecated for a while. Use the net library. It’s much, much better.

“1. SetGravity - [C]:-1” is part of the stack trace.

First part is the stack position. (This is 1 because this is the function that caused the error)
Second part is the function name for said stack position.
Third part is location. (This is [C] because SetGravity isn’t a function created in Lua)
Fourth part is the line on which the error occurred. (This is -1 because this isn’t a function created in Lua)

Generally you can stick to just looking at the error message (“Tried to use a NULL entity!”) and location/file information on the first line ("[ERROR] gamemodes/bhop/gamemode/sh_timer.lua:26"). If you for example needed to figure out the calling function (e.g. to find out where invalid input came from) then you’d use the stack trace.