fix: some time the PlayerChangedTeam gmInteResetTimeLastTeamChange was call before saving the time of the last team change

This commit is contained in:
Linventif 2025-03-20 03:10:23 +00:00
parent 3ebd9c0989
commit be3a44760d
2 changed files with 10 additions and 6 deletions

View File

@ -112,11 +112,14 @@ hook.Add("PlayerInitialSpawn", "gmInte:Player:InitialSpawn", function(ply) gmInt
hook.Add("PlayerGiveSWEP", "gmInte:Player:SWEPs", function(ply, class, swep) gmInte.postLogPlayerGive(ply, class, swep) end)
hook.Add("PlayerDeath", "gmInte:Player:Death", function(ply, inflictor, attacker) gmInte.playerDeath(ply, inflictor, attacker) end)
hook.Add("PlayerHurt", "gmInte:Player:Hurt", function(ply, attacker, healthRemaining, damageTaken) gmInte.postLogPlayerHurt(ply, attacker, healthRemaining, damageTaken) end)
hook.Add("PlayerChangedTeam", "gmInte:Player:ChangedTeam", function(ply, oldTeam, newTeam) gmInte.playerChangedTeam(ply, oldTeam, newTeam) end)
hook.Add("PlayerSpawnedProp", "gmInte:Player:SpawnedProp", function(ply, model, ent) gmInte.postLogPlayerSpawnedSomething("prop", ply, ent, model) end)
hook.Add("PlayerSpawnedSENT", "gmInte:Player:SpawnedSENT", function(ply, ent) gmInte.postLogPlayerSpawnedSomething("sent", ply, ent) end)
hook.Add("PlayerSpawnedNPC", "gmInte:Player:SpawnedNPC", function(ply, ent) gmInte.postLogPlayerSpawnedSomething("npc", ply, ent) end)
hook.Add("PlayerSpawnedVehicle", "gmInte:Player:SpawnedVehicle", function(ply, ent) gmInte.postLogPlayerSpawnedSomething("vehicle", ply, ent) end)
hook.Add("PlayerSpawnedEffect", "gmInte:Player:SpawnedEffect", function(ply, model, ent) gmInte.postLogPlayerSpawnedSomething("effect", ply, ent, model) end)
hook.Add("PlayerSpawnedRagdoll", "gmInte:Player:SpawnedRagdoll", function(ply, model, ent) gmInte.postLogPlayerSpawnedSomething("ragdoll", ply, ent, model) end)
hook.Add("PlayerSpawnedSWEP", "gmInte:Player:SpawnedSWEP", function(ply, ent) gmInte.postLogPlayerSpawnedSomething("swep", ply, ent) end)
hook.Add("PlayerSpawnedSWEP", "gmInte:Player:SpawnedSWEP", function(ply, ent) gmInte.postLogPlayerSpawnedSomething("swep", ply, ent) end)
hook.Add("PlayerChangedTeam", "gmInte:Player:ChangedTeam", function(ply, oldTeam, newTeam)
gmInte.playerChangedTeam(ply, oldTeam, newTeam)
ply:gmInteResetTimeLastTeamChange()
end)

View File

@ -11,6 +11,10 @@ function ply:gmIntGetTimeLastTeamChange()
return self.gmIntTimeLastTeamChange || RealTime()
end
function ply:gmInteResetTimeLastTeamChange()
self.gmIntTimeLastTeamChange = RealTime()
end
function ply:gmInteGetBranch()
return CLIENT && BRANCH || self.branch || "unknown"
end
@ -147,7 +151,4 @@ 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)
// on team change reset the time
hook.Add("PlayerChangedTeam", "gmInte:Player:ChangedTeam:ResetTime", function(ply) ply.gmIntTimeLastTeamChange = RealTime() end)
end)