
Hooks and callbacks that provide entities will always provide valid ones, with PreDrawViewModel being the exception due to a bug(?), but that provides nil instead of NULL. Note that worldspawn:IsValid() returns false, so if you are wanting the world to be considered a valid entity, you can check SomeEntity = NULL instead. NOTE: Trace result entities will always be valid if tr.Hit = true/tr.Fraction != 1 (same thing). SWEP.Holster can provide a NULL weapon if the weapon is being removed, or the player is switching to NULL.This can be from an async callback, hook, timer, or just storing the entity for later use after a set amount of time. Stored EHandles after time has passed.
Entities returned from other entity functions (GetParent, GetActiveWeapon, etc.). Entities created or accessed with the ents.Create(), Entity(), Player(), or LocalPlayer() functions. Entity that is networked through the net library. Anyway, you CAN trust entities to not be NULL here's a list of rules that I made for when to do validity checks: It would be great if "if (!NULL) then" worked in Lua, but I guess it does have the benefit of being able to run ent:IsValid on it to abstract all entities validity checks. Why the developer of DarkRP is responsible for this issue unknown - gamemodes/darkrp/gamemode/modules/chat/sv_a:255Ĥ. callback - gamemodes/darkrp/gamemode/modules/chat/sv_a:17ģ. callback - gamemodes/darkrp/gamemode/modules/hungermod/sv_a:74. gamemodes/darkrp/gamemode/modules/hungermod/sv_a:74: attempt to call method 'Setowning_ent' (a nil value) unknown - lua/includes/extensions/net.lua:32 func - gamemodes/darkrp/entities/entities/chatindicator/a:29ģ. gamemodes/darkrp/entities/entities/chatindicator/a:29: Tried to use a NULL entity! unknown - gamemodes/sandbox/gamemode/a:27ĥ. GMODSpawnProp - gamemodes/sandbox/gamemode/a:169Ĥ. DoPlayerEntitySpawn - gamemodes/darkrp/gamemode/modules/fpp/pp/server/a:163ģ. IsEmpty - gamemodes/darkrp/gamemode/modules/fpp/pp/server/a:120. gamemodes/darkrp/gamemode/modules/fpp/pp/server/a:120: attempt to index local 'ent' (a nil value) unknown - gamemodes/darkrp/gamemode/modules/base/sv_gamemode_a:603ĩ. PlayerSelectSpawn - gamemodes/base/gamemode/a:479ħ. unknown - gamemodes/darkrp/gamemode/modules/base/sv_gamemode_a:434ĥ. createMoneyBag - gamemodes/darkrp/gamemode/modules/money/sv_a:44ģ. gamemodes/darkrp/gamemode/modules/money/sv_a:44: Tried to use a NULL entity!Ģ. Its a lua error How to make the bug happen Lua errors