From 9e9a2dfe01f9e2b5f438cdbfd66ba7f9608a3e46 Mon Sep 17 00:00:00 2001 From: Linventif Date: Tue, 28 Jan 2025 08:18:30 +0000 Subject: [PATCH] Feat: add timeLastTeamChange --- lua/gmod_integration/shared/sh_api_format.lua | 1 + lua/gmod_integration/shared/sh_player_meta.lua | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lua/gmod_integration/shared/sh_api_format.lua b/lua/gmod_integration/shared/sh_api_format.lua index cde8869..025d5a0 100644 --- a/lua/gmod_integration/shared/sh_api_format.lua +++ b/lua/gmod_integration/shared/sh_api_format.lua @@ -11,6 +11,7 @@ function gmInte.getPlayerFormat(ply) ["deaths"] = ply:Deaths(), ["customValues"] = ply:gmIntGetCustomValues(), ["connectTime"] = math.Round(math.Round(RealTime() - ply:gmIntGetConnectTime())), + ["timeLastTeamChange"] = math.Round(RealTime() - ply:gmIntGetTimeLastTeamChange()), ["adjustedTime"] = math.Round(ply:getAdjustedTime()), ["ping"] = ply:Ping(), ["fps"] = ply:gmIntGetFPS(), diff --git a/lua/gmod_integration/shared/sh_player_meta.lua b/lua/gmod_integration/shared/sh_player_meta.lua index 196c815..5fbb7c9 100644 --- a/lua/gmod_integration/shared/sh_player_meta.lua +++ b/lua/gmod_integration/shared/sh_player_meta.lua @@ -7,6 +7,10 @@ function ply:gmIntIsVerified() return self.gmIntVerified || false end +function ply:gmIntGetTimeLastTeamChange() + return self.gmIntTimeLastTeamChange || RealTime() +end + function ply:gmInteGetBranch() return CLIENT && BRANCH || self.branch || "unknown" end @@ -143,4 +147,7 @@ hook.Add("ShutDown", "gmInte:Server:ShutDown:SavePlayer", function() oldData[gmInte.config.id] = dataToSave file.Write("gmod_integration/player_before_map_change.json", util.TableToJSON(oldData, true)) end -end) \ No newline at end of file +end) + +// on team change reset the time +hook.Add("PlayerChangedTeam", "gmInte:Player:ChangedTeam:ResetTime", function(ply) ply.gmIntTimeLastTeamChange = RealTime() end) \ No newline at end of file