diff --git a/lua/nitrous/optimizations/shared/player_steamid.lua b/lua/nitrous/optimizations/shared/player_steamid.lua index 69f0364..aadf15e 100644 --- a/lua/nitrous/optimizations/shared/player_steamid.lua +++ b/lua/nitrous/optimizations/shared/player_steamid.lua @@ -1,23 +1,33 @@ local meta = FindMetaTable( "Player" ) +local entMeta = FindMetaTable( "Entity" ) +local getTable = entMeta.GetTable meta.GMN_SteamID = GMN.StoreOriginal( "Player:SteamID", meta.SteamID ) function meta:SteamID() - local cached = self:GetTable().GMN_SteamIDVar + local tbl = getTable( self ) + if tbl == nil then return self:GMN_SteamID() end + + local cached = tbl.GMN_SteamIDVar if cached then return cached end local id = self:GMN_SteamID() - self.GMN_SteamIDVar = id + tbl.GMN_SteamIDVar = id + return id end meta.GMN_SteamID64 = GMN.StoreOriginal( "Player:SteamID64", meta.SteamID64 ) function meta:SteamID64() - local cached = self:GetTable().GMN_SteamID64Var + local tbl = getTable( self ) + if tbl == nil then return self:GMN_SteamID64() end + + local cached = tbl.GMN_SteamID64Var if cached then return cached end local id = self:GMN_SteamID64() - self.GMN_SteamID64Var = id + tbl.GMN_SteamID64Var = id + return id end