From 22e67cdc9da1fb853f190d0077a6ef8d235c5c51 Mon Sep 17 00:00:00 2001 From: zaCade Date: Wed, 10 Apr 2019 20:24:38 +0200 Subject: [PATCH] hlstats_ze: Optimize code slightly, and only count alive humans. --- hlstatsx/scripting/hlstatsx_ze.sp | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/hlstatsx/scripting/hlstatsx_ze.sp b/hlstatsx/scripting/hlstatsx_ze.sp index f3e3dd03..c516fe20 100644 --- a/hlstatsx/scripting/hlstatsx_ze.sp +++ b/hlstatsx/scripting/hlstatsx_ze.sp @@ -132,22 +132,31 @@ public void OnRoundEnding(Event hEvent, const char[] sEvent, bool bDontBroadcast bool bAwardHumans = ((g_tMinimalRoundDuration == INVALID_HANDLE) && (hEvent.GetInt("winner") == CS_TEAM_CT)); bool bAwardZombies = ((g_tMinimalRoundDuration == INVALID_HANDLE) && (hEvent.GetInt("winner") == CS_TEAM_T)); + int iAliveHumans; + + for (int client = 1; client <= MaxClients; client++) + { + if (IsValidClient(client) && GetClientTeam(client) == CS_TEAM_CT) + iAliveHumans++; + } + for (int client = 1; client <= MaxClients; client++) { if (IsValidClient(client)) { - int HumanCount = GetTeamClientCount(CS_TEAM_CT); - - if (bAwardHumans && g_bIsHuman[client] && HumanCount == 1) + if (bAwardHumans && g_bIsHuman[client]) { - LogPlayerEvent(client, "triggered", "ze_h_win_solo"); - } - else if (bAwardHumans && g_bIsHuman[client]) - { - char sPlayerEvent[32]; - Format(sPlayerEvent, sizeof(sPlayerEvent), "ze_h_win_%d", g_cvarDifficultyHuman.IntValue); + if (iAliveHumans == 1) + { + LogPlayerEvent(client, "triggered", "ze_h_win_solo"); + } + else + { + char sPlayerEvent[32]; + Format(sPlayerEvent, sizeof(sPlayerEvent), "ze_h_win_%d", g_cvarDifficultyHuman.IntValue); - LogPlayerEvent(client, "triggered", sPlayerEvent); + LogPlayerEvent(client, "triggered", sPlayerEvent); + } } else if (bAwardZombies && g_bIsZombie[client]) {