From ef175ca4888d250a05dcfc6e42a0e7456f240333 Mon Sep 17 00:00:00 2001 From: Richard Helgeby Date: Tue, 27 Dec 2011 09:05:27 +0100 Subject: [PATCH] Small timer fixes. Added cvar zr_roundend_balance_teams. See details. Added cvar for disabling team balancing on round end (for use with custom team balancer): zr_roundend_balance_teams. Disabling this will cause players to remain on their current team when a new round starts. If zombies win, everyone will remain on the terrorists team. Fixed invalid handle error after a map change. Fixed language code typo in translations. Infection countdown is no longer displayed if the infection delay is just one second. --- .../translations/es/zombiereloaded.phrases.txt | 2 +- .../translations/no/zombiereloaded.phrases.txt | 2 +- .../translations/ru/zombiereloaded.phrases.txt | 2 +- .../cfg/sourcemod/zombiereloaded/zombiereloaded.cfg | 3 +++ src/zr/cvars.inc | 2 ++ src/zr/infect.inc | 9 +++++---- src/zr/roundend.inc | 11 ++++++----- 7 files changed, 19 insertions(+), 12 deletions(-) diff --git a/cstrike/addons/sourcemod/translations/es/zombiereloaded.phrases.txt b/cstrike/addons/sourcemod/translations/es/zombiereloaded.phrases.txt index 0c8f0dc..89621a7 100644 --- a/cstrike/addons/sourcemod/translations/es/zombiereloaded.phrases.txt +++ b/cstrike/addons/sourcemod/translations/es/zombiereloaded.phrases.txt @@ -362,7 +362,7 @@ "Infect countdown" { - "en" "First infection in {1} seconds." + "es" "First infection in {1} seconds." } // Menu diff --git a/cstrike/addons/sourcemod/translations/no/zombiereloaded.phrases.txt b/cstrike/addons/sourcemod/translations/no/zombiereloaded.phrases.txt index 7f10b76..4da8683 100644 --- a/cstrike/addons/sourcemod/translations/no/zombiereloaded.phrases.txt +++ b/cstrike/addons/sourcemod/translations/no/zombiereloaded.phrases.txt @@ -361,7 +361,7 @@ "Infect countdown" { - "en" "Første infeksjon om {1} sekunder." + "no" "Første infeksjon om {1} sekunder." } // Menu diff --git a/cstrike/addons/sourcemod/translations/ru/zombiereloaded.phrases.txt b/cstrike/addons/sourcemod/translations/ru/zombiereloaded.phrases.txt index 5b40cd5..fff0c2a 100644 --- a/cstrike/addons/sourcemod/translations/ru/zombiereloaded.phrases.txt +++ b/cstrike/addons/sourcemod/translations/ru/zombiereloaded.phrases.txt @@ -362,7 +362,7 @@ "Infect countdown" { - "en" "First infection in {1} seconds." + "ru" "First infection in {1} seconds." } // Menu diff --git a/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg b/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg index c230cff..d463c9a 100644 --- a/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg +++ b/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg @@ -428,6 +428,9 @@ zr_roundend_overlays_zombie "overlays/zr/zombies_win" // Default: "overlays/zr/humans_win" zr_roundend_overlays_human "overlays/zr/humans_win" +// Balances the team every time the round ends. Disable this if you use something else to balance teams. +// Default: "1" +zr_roundend_balance_teams "1" // ---------------------------------------------------------------------------- // Account (module) diff --git a/src/zr/cvars.inc b/src/zr/cvars.inc index ce3390c..62ecd9a 100644 --- a/src/zr/cvars.inc +++ b/src/zr/cvars.inc @@ -95,6 +95,7 @@ enum CvarsList Handle:CVAR_ROUNDEND_OVERLAY, Handle:CVAR_ROUNDEND_OVERLAY_ZOMBIE, Handle:CVAR_ROUNDEND_OVERLAY_HUMAN, + Handle:CVAR_ROUNDEND_BALANCE_TEAMS, Handle:CVAR_INFECT_SPAWNTIME_MIN, Handle:CVAR_INFECT_SPAWNTIME_MAX, Handle:CVAR_INFECT_CONSECUTIVE_BLOCK, @@ -369,6 +370,7 @@ CvarsCreate() g_hCvarsList[CVAR_ROUNDEND_OVERLAY] = CreateConVar("zr_roundend_overlay", "1", "Show specified overlay to players depending on winner when the round ends."); g_hCvarsList[CVAR_ROUNDEND_OVERLAY_HUMAN] = CreateConVar("zr_roundend_overlays_human", "overlays/zr/humans_win", "Overlay, relative to \"materials\" folder, to display when humans win the round. [Dependency: zr_roundend_overlay]"); g_hCvarsList[CVAR_ROUNDEND_OVERLAY_ZOMBIE] = CreateConVar("zr_roundend_overlays_zombie", "overlays/zr/zombies_win", "Overlay, relative to \"materials\" folder, to display when zombies win the round. [Dependency: zr_roundend_overlay]"); + g_hCvarsList[CVAR_ROUNDEND_BALANCE_TEAMS] = CreateConVar("zr_roundend_balance_teams", "1", "Balances the team every time the round ends. Disable this if you use something else to balance teams."); // =========================== diff --git a/src/zr/infect.inc b/src/zr/infect.inc index 15ff065..e9bc1b7 100644 --- a/src/zr/infect.inc +++ b/src/zr/infect.inc @@ -78,9 +78,10 @@ new bool:bInfectImmune[MAXPLAYERS + 1][2]; */ InfectOnMapStart() { - // Stop timers if running. - ZREndTimer(tInfect); - ZREndTimer(tInfectCountdown); + // Reset timer handles. Infect timers are invalidated on a map change if + // they are still running, so these handles no longer point to valid timers. + tInfect = INVALID_HANDLE; + tInfectCountdown = INVALID_HANDLE; } /** @@ -378,7 +379,7 @@ InfectOnRoundFreezeEnd() // Check cvar and start a countdown timer if enabled. new bool:countdown = GetConVarBool(g_hCvarsList[CVAR_INFECT_MZOMBIE_COUNTDOWN]); - if (countdown) + if (countdown && randomtime > 1.0) { // Store the time until infection, and initialize the counter. new Handle:hCountdownData = CreateDataPack(); diff --git a/src/zr/roundend.inc b/src/zr/roundend.inc index 6316d79..a2359e4 100644 --- a/src/zr/roundend.inc +++ b/src/zr/roundend.inc @@ -185,8 +185,11 @@ RoundEndOnRoundEnd(reason) // Display the overlay to all clients. RoundEndOverlayStart(outcome); - // Balance teams. - RoundEndBalanceTeams(); + // Balance teams if enabled. + if (GetConVarBool(g_hCvarsList[CVAR_ROUNDEND_BALANCE_TEAMS])) + { + RoundEndBalanceTeams(); + } } /** @@ -327,9 +330,7 @@ RoundEndTerminateRound(Float:delay, RoundEndOutcome:outcome = Restart) } /** - * Balances teams - * - * @param spawn If true, it will respawn player after switching their team. + * Balances teams. */ RoundEndBalanceTeams() {