Fix late-joiners loss of points at round end

master
David Vogel 6 years ago
parent 34d35ea711
commit cfc4ba44f7

@ -69,7 +69,7 @@ function meta:GetSavedPoints()
if SERVER then if SERVER then
local points = self:GetPData("zs_savedpoints", settings.StartingSavedPoints) local points = self:GetPData("zs_savedpoints", settings.StartingSavedPoints)
self:SetNWInt("zs_savedpoints", points) self:SetNWInt("zs_savedpoints", points)
--print("### PS Loaded: "..points) --print("### PS Loaded:", points, "for", tostring(self))
return points return points
end end
@ -83,7 +83,7 @@ if not SERVER then return end
function meta:SetSavedPoints(amount) function meta:SetSavedPoints(amount)
if amount < settings.MinimumPoints then amount = settings.MinimumPoints end if amount < settings.MinimumPoints then amount = settings.MinimumPoints end
amount = math.Round(amount) amount = math.Round(amount)
--print("### PS Saved: "..amount) --print("### PS Saved: ", amount, "for", tostring(self))
self:SetNWInt("zs_savedpoints", amount) self:SetNWInt("zs_savedpoints", amount)
self:SetPData("zs_savedpoints", amount) self:SetPData("zs_savedpoints", amount)
end end

@ -80,7 +80,7 @@ hook.Add("PostEndRound", "pointsave_givedapoints", function(winner)
if PointSaving_shouldIgnoreMap(game.GetMap()) then return end if PointSaving_shouldIgnoreMap(game.GetMap()) then return end
timer.Simple(0, function() timer.Simple(0, function()
print("point bonus hook") --print("point bonus hook")
local zombiePercentCalcMap = 1 local zombiePercentCalcMap = 1
if totalIntervalCounter > 0 then if totalIntervalCounter > 0 then
zombiePercentCalcMap = (zombieIntervalCounter / totalIntervalCounter) zombiePercentCalcMap = (zombieIntervalCounter / totalIntervalCounter)
@ -149,8 +149,8 @@ hook.Add("PostEndRound", "pointsave_givedapoints", function(winner)
local pointsToGivePly local pointsToGivePly
local points = math.Round(ply:GetSavedPoints()) local points = math.Round(ply:GetSavedPoints())
local gainedPoints = points - (ply.PointSaving_StartPoints or 0) local gainedPoints = points - (ply.PointSaving_StartPoints or 0)
print("GAINED: "..gainedPoints) --print("GAINED: "..gainedPoints)
if gainedPoints < 0 then gainedPoints = 0 end 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) -- Calculate points to give for each player (Depending on if the round was lost or won)
if ply:Team() == TEAM_HUMAN then if ply:Team() == TEAM_HUMAN then
points = math.Round(ply:GetPoints()) points = math.Round(ply:GetPoints())

Loading…
Cancel
Save