diff --git a/hlstatsx/scripting/hlstatsx_difficulty.sp b/hlstatsx/scripting/hlstatsx_difficulty.sp index fa70366e..812bec49 100644 --- a/hlstatsx/scripting/hlstatsx_difficulty.sp +++ b/hlstatsx/scripting/hlstatsx_difficulty.sp @@ -2,15 +2,14 @@ #include #include -new bool:G_bIsHuman[MAXPLAYERS+1]; -new bool:G_bIsZombie[MAXPLAYERS+1]; +bool G_bIsHuman[MAXPLAYERS+1]; +bool G_bIsZombie[MAXPLAYERS+1]; -new Handle:G_hCvar_Difficulty_Humans; -new Handle:G_hCvar_Difficulty_Zombies; -new Handle:G_hCvar_Difficulty_Humans_BlockTime; +ConVar G_hCvar_Difficulty_Humans; +ConVar G_hCvar_Difficulty_Zombies; +ConVar G_hCvar_Difficulty_Humans_BlockTime; -bool g_bHumanPointsEnabled = false; -Handle g_hTimer = INVALID_HANDLE; +Handle g_hHumanPointsTimer; //---------------------------------------------------------------------------------------------------- // Purpose: @@ -62,13 +61,10 @@ public ZR_OnClientHumanPost(client, bool:respawn, bool:protect) //---------------------------------------------------------------------------------------------------- public Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast) { - if (g_hTimer != INVALID_HANDLE) - { - KillTimer(g_hTimer); - g_hTimer = INVALID_HANDLE; - } - g_bHumanPointsEnabled = false; - g_hTimer = CreateTimer(GetConVarFloat(G_hCvar_Difficulty_Humans_BlockTime), EnableHumanPoints, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE); + if (g_hHumanPointsTimer != INVALID_HANDLE && KillTimer(g_hHumanPointsTimer)) + g_hHumanPointsTimer = INVALID_HANDLE; + + g_hHumanPointsTimer = CreateTimer(G_hCvar_Difficulty_Humans_BlockTime.FloatValue, OnHumanPointsTimer); for (new client = 1; client <= MaxClients; client++) { @@ -92,10 +88,9 @@ public Action:Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadca //---------------------------------------------------------------------------------------------------- // Purpose: //---------------------------------------------------------------------------------------------------- -public Action EnableHumanPoints(Handle timer) +public Action OnHumanPointsTimer(Handle timer) { - g_bHumanPointsEnabled = true; - g_hTimer = INVALID_HANDLE; + g_hHumanPointsTimer = INVALID_HANDLE; } //---------------------------------------------------------------------------------------------------- @@ -103,11 +98,12 @@ public Action EnableHumanPoints(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."); return; } + for (new client = 1; client <= MaxClients; 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))) 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))) 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); } } }