Skip to content

Commit

Permalink
Add comments with link to PR
Browse files Browse the repository at this point in the history
  • Loading branch information
FPtje committed Dec 16, 2024
1 parent 08df78f commit 8627c08
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions gamemode/modules/base/cl_entityvars.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ function pmeta:getDarkRPVar(var, fallback)

-- Special case: when in the EntityRemoved hook, UserID returns -1. In this
-- case, hope that we still have a stored userID lying around somewhere.
-- See https://github.com/FPtje/DarkRP/pull/3270
if user_id == -1 then
user_id = self._darkrp_stored_user_id_for_entity_removed_hook
end
Expand Down Expand Up @@ -111,15 +112,12 @@ net.Receive("DarkRP_DarkRPVarDisconnect", function(len)
end

hook.Add("EntityRemoved", hook_name, function(ent)
-- NOTE: ent:UserID() will return -1 in this hook, so there is no use to
-- compare UserIDs. That also means that getting DarkRPVars in the
-- EntityRemoved hook is futile, as the lookup of -1 in
-- DarkRP.ClientsideDarkRPVars wil fail.
if ent ~= ply then return end
hook.Remove("EntityRemoved", hook_name)

-- Placing this in a timer allows for the rest of the hook runners to
-- still use the DarkRPVars until the entity is _really_ gone.
-- See https://github.com/FPtje/DarkRP/pull/3270
timer.Simple(0, function()
DarkRP.ClientsideDarkRPVars[userID] = nil
end)
Expand Down

0 comments on commit 8627c08

Please sign in to comment.