hlstats_ze: Optimize code slightly, and only count alive humans.

This commit is contained in:
zaCade 2019-04-10 20:24:38 +02:00
parent 5cc005f9c9
commit 22e67cdc9d

View File

@ -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 bAwardHumans = ((g_tMinimalRoundDuration == INVALID_HANDLE) && (hEvent.GetInt("winner") == CS_TEAM_CT));
bool bAwardZombies = ((g_tMinimalRoundDuration == INVALID_HANDLE) && (hEvent.GetInt("winner") == CS_TEAM_T)); 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++) for (int client = 1; client <= MaxClients; client++)
{ {
if (IsValidClient(client)) if (IsValidClient(client))
{ {
int HumanCount = GetTeamClientCount(CS_TEAM_CT); if (bAwardHumans && g_bIsHuman[client])
if (bAwardHumans && g_bIsHuman[client] && HumanCount == 1)
{ {
LogPlayerEvent(client, "triggered", "ze_h_win_solo"); if (iAliveHumans == 1)
} {
else if (bAwardHumans && g_bIsHuman[client]) LogPlayerEvent(client, "triggered", "ze_h_win_solo");
{ }
char sPlayerEvent[32]; else
Format(sPlayerEvent, sizeof(sPlayerEvent), "ze_h_win_%d", g_cvarDifficultyHuman.IntValue); {
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]) else if (bAwardZombies && g_bIsZombie[client])
{ {