From 5c78fae9a691b826b68e871f43dd01054e83c083 Mon Sep 17 00:00:00 2001 From: Linventif Date: Thu, 21 Nov 2024 22:50:52 +0000 Subject: [PATCH] Fix: somevar typo --- lua/gmod_integration/shared/sh_api_format.lua | 2 +- .../shared/sh_player_meta.lua | 20 ++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/lua/gmod_integration/shared/sh_api_format.lua b/lua/gmod_integration/shared/sh_api_format.lua index d48076b..cde8869 100644 --- a/lua/gmod_integration/shared/sh_api_format.lua +++ b/lua/gmod_integration/shared/sh_api_format.lua @@ -11,7 +11,7 @@ function gmInte.getPlayerFormat(ply) ["deaths"] = ply:Deaths(), ["customValues"] = ply:gmIntGetCustomValues(), ["connectTime"] = math.Round(math.Round(RealTime() - ply:gmIntGetConnectTime())), - ["ajustTime"] = math.Round(ply:getAjustTime()), + ["adjustedTime"] = math.Round(ply:getAdjustedTime()), ["ping"] = ply:Ping(), ["fps"] = ply:gmIntGetFPS(), ["position"] = gmInte.getVectorFormat(ply:GetPos()), diff --git a/lua/gmod_integration/shared/sh_player_meta.lua b/lua/gmod_integration/shared/sh_player_meta.lua index dc1e527..b2d27f5 100644 --- a/lua/gmod_integration/shared/sh_player_meta.lua +++ b/lua/gmod_integration/shared/sh_player_meta.lua @@ -75,7 +75,7 @@ function ply:gmIntGetFPS() end gmInte.restoreFileCache = gmInte.restoreFileCache || {} -function ply:getAjustTime() +function ply:getAdjustedTime() if SERVER then if table.IsEmpty(gmInte.restoreFileCache) then if file.Exists("gm_integration/player_before_map_change.json", "DATA") then @@ -101,6 +101,24 @@ function ply:getAjustTime() return gmInte.restoreFileCache.playersList[self:SteamID()].connectTime || 0 end +if SERVER then + gameevent.Listen("player_connect") + hook.Add("player_connect", "gmInte:Player:Connect:RemoveRestore", function(data) + if table.IsEmpty(gmInte.restoreFileCache) then + if file.Exists("gm_integration/player_before_map_change.json", "DATA") then + gmInte.restoreFileCache = util.JSONToTable(file.Read("gm_integration/player_before_map_change.json", "DATA")) + else + return + end + end + + if gmInte.restoreFileCache.playersList && gmInte.restoreFileCache.playersList[data.networkid] then + gmInte.restoreFileCache.playersList[data.networkid] = nil + file.Write("gm_integration/player_before_map_change.json", util.TableToJSON(gmInte.restoreFileCache, true)) + end + end) +end + hook.Add("ShutDown", "gmInte:Server:ShutDown:SavePlayer", function() local dataToSave = { ["version"] = "1.0",