Cleanup error, and change syntax slightly

This commit is contained in:
zaCade 2018-09-07 22:13:24 +02:00
parent fe4cfca3dd
commit e939f7bff7

View File

@ -2,15 +2,14 @@
#include <cstrike> #include <cstrike>
#include <zombiereloaded> #include <zombiereloaded>
new bool:G_bIsHuman[MAXPLAYERS+1]; bool G_bIsHuman[MAXPLAYERS+1];
new bool:G_bIsZombie[MAXPLAYERS+1]; bool G_bIsZombie[MAXPLAYERS+1];
new Handle:G_hCvar_Difficulty_Humans; ConVar G_hCvar_Difficulty_Humans;
new Handle:G_hCvar_Difficulty_Zombies; ConVar G_hCvar_Difficulty_Zombies;
new Handle:G_hCvar_Difficulty_Humans_BlockTime; ConVar G_hCvar_Difficulty_Humans_BlockTime;
bool g_bHumanPointsEnabled = false; Handle g_hHumanPointsTimer;
Handle g_hTimer = INVALID_HANDLE;
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
@ -62,13 +61,10 @@ public ZR_OnClientHumanPost(client, bool:respawn, bool:protect)
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast) public Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{ {
if (g_hTimer != INVALID_HANDLE) if (g_hHumanPointsTimer != INVALID_HANDLE && KillTimer(g_hHumanPointsTimer))
{ g_hHumanPointsTimer = INVALID_HANDLE;
KillTimer(g_hTimer);
g_hTimer = INVALID_HANDLE; g_hHumanPointsTimer = CreateTimer(G_hCvar_Difficulty_Humans_BlockTime.FloatValue, OnHumanPointsTimer);
}
g_bHumanPointsEnabled = false;
g_hTimer = CreateTimer(GetConVarFloat(G_hCvar_Difficulty_Humans_BlockTime), EnableHumanPoints, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE);
for (new client = 1; client <= MaxClients; client++) for (new client = 1; client <= MaxClients; client++)
{ {
@ -92,10 +88,9 @@ public Action:Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadca
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public Action EnableHumanPoints(Handle timer) public Action OnHumanPointsTimer(Handle timer)
{ {
g_bHumanPointsEnabled = true; g_hHumanPointsTimer = INVALID_HANDLE;
g_hTimer = INVALID_HANDLE;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
@ -103,11 +98,12 @@ public Action EnableHumanPoints(Handle timer)
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public Action:OnHumansWin(Handle:timer) public Action:OnHumansWin(Handle:timer)
{ {
if (!g_bHumanPointsEnabled) if (g_hHumanPointsTimer != INVALID_HANDLE)
{ {
PrintToChatAll("[SM] Round ended too fast. Humans will not be rewarded for the Win."); PrintToChatAll("[SM] Round ended too fast. Humans will not be rewarded for the Win.");
return; return;
} }
for (new client = 1; client <= MaxClients; client++) for (new client = 1; client <= MaxClients; client++)
{ {
if (IsClientInGame(client) && IsPlayerAlive(client) && !IsClientObserver(client) && !IsFakeClient(client)) if (IsClientInGame(client) && IsPlayerAlive(client) && !IsClientObserver(client) && !IsFakeClient(client))
@ -118,7 +114,7 @@ public Action:OnHumansWin(Handle:timer)
if (!GetClientAuthString(client, sAuthid, sizeof(sAuthid))) if (!GetClientAuthString(client, sAuthid, sizeof(sAuthid)))
Format(sAuthid, sizeof(sAuthid), "UNKNOWN"); Format(sAuthid, sizeof(sAuthid), "UNKNOWN");
LogToGame("\"%N<%d><%s><%s>\" triggered \"human_win_%i\"", client, GetClientUserId(client), sAuthid, "CT", GetConVarInt(G_hCvar_Difficulty_Humans)); LogToGame("\"%N<%d><%s><%s>\" triggered \"human_win_%i\"", client, GetClientUserId(client), sAuthid, "CT", G_hCvar_Difficulty_Humans.IntValue);
} }
} }
} }
@ -139,7 +135,7 @@ public Action:OnZombiesWin(Handle:timer)
if (!GetClientAuthString(client, sAuthid, sizeof(sAuthid))) if (!GetClientAuthString(client, sAuthid, sizeof(sAuthid)))
Format(sAuthid, sizeof(sAuthid), "UNKNOWN"); Format(sAuthid, sizeof(sAuthid), "UNKNOWN");
LogToGame("\"%N<%d><%s><%s>\" triggered \"zombie_win_%i\"", client, GetClientUserId(client), sAuthid, "TERRORIST", GetConVarInt(G_hCvar_Difficulty_Zombies)); LogToGame("\"%N<%d><%s><%s>\" triggered \"zombie_win_%i\"", client, GetClientUserId(client), sAuthid, "TERRORIST", G_hCvar_Difficulty_Zombies.IntValue);
} }
} }
} }