From cfc4ba44f74656677014e22379bf93d8be17ab31 Mon Sep 17 00:00:00 2001 From: David Vogel Date: Thu, 2 Aug 2018 16:03:54 +0200 Subject: [PATCH] Fix late-joiners loss of points at round end --- lua/autorun/server/pointsaving.lua | 4 ++-- lua/autorun/server/pointsaving_mapstats.lua | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lua/autorun/server/pointsaving.lua b/lua/autorun/server/pointsaving.lua index 5accaa0..9db552f 100644 --- a/lua/autorun/server/pointsaving.lua +++ b/lua/autorun/server/pointsaving.lua @@ -69,7 +69,7 @@ function meta:GetSavedPoints() if SERVER then local points = self:GetPData("zs_savedpoints", settings.StartingSavedPoints) self:SetNWInt("zs_savedpoints", points) - --print("### PS Loaded: "..points) + --print("### PS Loaded:", points, "for", tostring(self)) return points end @@ -83,7 +83,7 @@ if not SERVER then return end function meta:SetSavedPoints(amount) if amount < settings.MinimumPoints then amount = settings.MinimumPoints end amount = math.Round(amount) - --print("### PS Saved: "..amount) + --print("### PS Saved: ", amount, "for", tostring(self)) self:SetNWInt("zs_savedpoints", amount) self:SetPData("zs_savedpoints", amount) end diff --git a/lua/autorun/server/pointsaving_mapstats.lua b/lua/autorun/server/pointsaving_mapstats.lua index d9f4c3c..2eb1441 100644 --- a/lua/autorun/server/pointsaving_mapstats.lua +++ b/lua/autorun/server/pointsaving_mapstats.lua @@ -80,7 +80,7 @@ hook.Add("PostEndRound", "pointsave_givedapoints", function(winner) if PointSaving_shouldIgnoreMap(game.GetMap()) then return end timer.Simple(0, function() - print("point bonus hook") + --print("point bonus hook") local zombiePercentCalcMap = 1 if totalIntervalCounter > 0 then zombiePercentCalcMap = (zombieIntervalCounter / totalIntervalCounter) @@ -149,8 +149,8 @@ hook.Add("PostEndRound", "pointsave_givedapoints", function(winner) local pointsToGivePly local points = math.Round(ply:GetSavedPoints()) local gainedPoints = points - (ply.PointSaving_StartPoints or 0) - print("GAINED: "..gainedPoints) - if gainedPoints < 0 then gainedPoints = 0 end + --print("GAINED: "..gainedPoints) + if gainedPoints < 0 or not ply.PointSaving_StartPoints then gainedPoints = 0 end -- Calculate points to give for each player (Depending on if the round was lost or won) if ply:Team() == TEAM_HUMAN then points = math.Round(ply:GetPoints())