Reset variables when round ends

This commit is contained in:
David Vogel 2018-07-16 17:08:36 +02:00
parent 1e4ba6002d
commit e90128431b

View File

@ -51,7 +51,9 @@ hook.Add("WaveStateChanged", "pointsave_zombieintervalactivator", function()
end end
end) end)
-- TODO: Reset counters on new round. local function resetVariables()
zombieIntervalCounter, totalIntervalCounter = 0, 0
end
local function postStatistics(mapParams, timesPlayed, freqMult, zombiePercentCalcMap) local function postStatistics(mapParams, timesPlayed, freqMult, zombiePercentCalcMap)
PrintMessage(HUD_PRINTTALK,"<c=0,255,255>This map has been played "..timesPlayed.." times with humans winning "..(mapParams.TimesWon).." times.("..(math.Round((mapParams.TimesWon/timesPlayed)*100)).."%)</c>") PrintMessage(HUD_PRINTTALK,"<c=0,255,255>This map has been played "..timesPlayed.." times with humans winning "..(mapParams.TimesWon).." times.("..(math.Round((mapParams.TimesWon/timesPlayed)*100)).."%)</c>")
@ -76,6 +78,7 @@ hook.Add("PostEndRound", "pointsave_givedapoints", function(winner)
PrintMessage(HUD_PRINTTALK, "No end of game points because zombies were not even playing half the time!") PrintMessage(HUD_PRINTTALK, "No end of game points because zombies were not even playing half the time!")
postStatistics(mapParams, timesPlayed, freqMult, zombiePercentCalcMap) postStatistics(mapParams, timesPlayed, freqMult, zombiePercentCalcMap)
saveMapParams(mapParams) saveMapParams(mapParams)
resetVariables()
return return
end end
@ -101,6 +104,7 @@ hook.Add("PostEndRound", "pointsave_givedapoints", function(winner)
PrintMessage(HUD_PRINTTALK,"Sorry, this map needs to be played at least "..(settings.MinimumRounds - timesPlayed).." more times, before you can get points for winning.") PrintMessage(HUD_PRINTTALK,"Sorry, this map needs to be played at least "..(settings.MinimumRounds - timesPlayed).." more times, before you can get points for winning.")
postStatistics(mapParams, timesPlayed, freqMult, zombiePercentCalcMap) postStatistics(mapParams, timesPlayed, freqMult, zombiePercentCalcMap)
saveMapParams(mapParams) saveMapParams(mapParams)
resetVariables()
return return
end end
@ -145,6 +149,7 @@ hook.Add("PostEndRound", "pointsave_givedapoints", function(winner)
-- Output general stats about this map -- Output general stats about this map
postStatistics(mapParams, timesPlayed, freqMult, zombiePercentCalcMap) postStatistics(mapParams, timesPlayed, freqMult, zombiePercentCalcMap)
resetVariables()
end) end)
end) end)