From 0fffcca1c2c0ed2ee75b53902d28f1036bb60215 Mon Sep 17 00:00:00 2001 From: Timo Smit Date: Wed, 7 Sep 2016 20:23:36 +0200 Subject: [PATCH] We actually have an event for team changes now, so move spree handling out of commands.lua --- luascripts/commands/commands.lua | 4 ---- luascripts/game/sprees.lua | 7 +++++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/luascripts/commands/commands.lua b/luascripts/commands/commands.lua index bcbbab8..68b2817 100644 --- a/luascripts/commands/commands.lua +++ b/luascripts/commands/commands.lua @@ -219,10 +219,6 @@ function commands.onclientcommand(clientId, cmdText) return 1 end - - stats.set(clientId, "currentKillSpree", 0) - stats.set(clientId, "currentDeathSpree", 0) - stats.set(clientId, "currentReviveSpree", 0) elseif wolfCmd == "callvote" then local voteArguments = {} for i = 2, et.trap_Argc() - 1 do diff --git a/luascripts/game/sprees.lua b/luascripts/game/sprees.lua index 22509f0..129ffb0 100644 --- a/luascripts/game/sprees.lua +++ b/luascripts/game/sprees.lua @@ -110,8 +110,15 @@ function sprees.onconnect(clientId, firstTime, isBot) end events.handle("onClientConnect", sprees.onconnect) +function sprees.onteamchange(clientId, old, new) + stats.set(clientId, "currentKillSpree", 0) + stats.set(clientId, "currentDeathSpree", 0) + stats.set(clientId, "currentReviveSpree", 0) +end + function sprees.ongamestatechange(gameState) if gameState == constants.GAME_STATE_RUNNING then + events.handle("onClientTeamChange", sprees.onteamchange) events.handle("onPlayerDeath", sprees.ondeath) events.handle("onPlayerRevive", sprees.onrevive) elseif gameState == constants.GAME_STATE_INTERMISSION then