From e90128431b1e4d83a8ec6181f82d14a25e2bcc71 Mon Sep 17 00:00:00 2001 From: David Vogel Date: Mon, 16 Jul 2018 17:08:36 +0200 Subject: [PATCH] Reset variables when round ends --- lua/autorun/server/pointsaving_mapstats.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lua/autorun/server/pointsaving_mapstats.lua b/lua/autorun/server/pointsaving_mapstats.lua index e030d7f..fd6de63 100644 --- a/lua/autorun/server/pointsaving_mapstats.lua +++ b/lua/autorun/server/pointsaving_mapstats.lua @@ -51,7 +51,9 @@ hook.Add("WaveStateChanged", "pointsave_zombieintervalactivator", function() end end) --- TODO: Reset counters on new round. +local function resetVariables() + zombieIntervalCounter, totalIntervalCounter = 0, 0 +end local function postStatistics(mapParams, timesPlayed, freqMult, zombiePercentCalcMap) PrintMessage(HUD_PRINTTALK,"This map has been played "..timesPlayed.." times with humans winning "..(mapParams.TimesWon).." times.("..(math.Round((mapParams.TimesWon/timesPlayed)*100)).."%)") @@ -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!") postStatistics(mapParams, timesPlayed, freqMult, zombiePercentCalcMap) saveMapParams(mapParams) + resetVariables() return 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.") postStatistics(mapParams, timesPlayed, freqMult, zombiePercentCalcMap) saveMapParams(mapParams) + resetVariables() return end @@ -145,6 +149,7 @@ hook.Add("PostEndRound", "pointsave_givedapoints", function(winner) -- Output general stats about this map postStatistics(mapParams, timesPlayed, freqMult, zombiePercentCalcMap) + resetVariables() end) end) \ No newline at end of file