From 01653a26363c033e93ad26fb9322f1575cd5e891 Mon Sep 17 00:00:00 2001 From: Greyscale Date: Thu, 18 Jun 2009 15:53:22 -0700 Subject: [PATCH] zr_infect now infects mother zombie if used before it has spawned. * Fixed a serious bug that could delay the game, the round end checker took dead clients in the count, so 1 dead ct and 9 zombies didn't end the game. * Small typo fix in anticamp, and got rid of a warning. --- .../translations/zombiereloaded.phrases.txt | 11 +- src/zr/infect.inc | 157 ++++++++++++------ src/zr/roundend.inc | 2 +- src/zr/volfeatures/volanticamp.inc | 2 +- src/zr/weapons/weapons.inc | 2 +- 5 files changed, 118 insertions(+), 56 deletions(-) diff --git a/cstrike/addons/sourcemod/translations/zombiereloaded.phrases.txt b/cstrike/addons/sourcemod/translations/zombiereloaded.phrases.txt index ba2cd3c..2574211 100644 --- a/cstrike/addons/sourcemod/translations/zombiereloaded.phrases.txt +++ b/cstrike/addons/sourcemod/translations/zombiereloaded.phrases.txt @@ -351,6 +351,12 @@ "en" "Player @green{1} @defaulthas been successfully infected." } + "Infect command infect mother successful" + { + "#format" "{1:s}" + "en" "Player @green{1} @defaulthas been successfully infected as the mother zombie." + } + "Infect command infect unsuccessful" { "#format" "{1:s}" @@ -369,11 +375,6 @@ "en" "Player @green{1} @defaultis already a human." } - "Infect command zombie has not spawned" - { - "en" "The mother zombie must spawn before player infection states can be changed." - } - // =========================== // Damage (core) // =========================== diff --git a/src/zr/infect.inc b/src/zr/infect.inc index dd5d461..a05373d 100644 --- a/src/zr/infect.inc +++ b/src/zr/infect.inc @@ -836,12 +836,6 @@ public Action:InfectInfectCommand(client, argc) return Plugin_Handled; } - if (!g_bZombieSpawned) - { - TranslationReplyToCommand(client, "Infect command zombie has not spawned"); - return Plugin_Handled; - } - decl String:target[MAX_NAME_LENGTH], String:targetname[MAX_NAME_LENGTH]; new targets[MAXPLAYERS], bool:tn_is_ml, result; @@ -849,7 +843,7 @@ public Action:InfectInfectCommand(client, argc) GetCmdArg(1, target, sizeof(target)); // Find a target. - result = ProcessTargetString(target, client, targets, sizeof(targets), COMMAND_FILTER_ALIVE | COMMAND_FILTER_NO_MULTI, targetname, sizeof(targetname), tn_is_ml); + result = ProcessTargetString(target, client, targets, sizeof(targets), COMMAND_FILTER_ALIVE , targetname, sizeof(targetname), tn_is_ml); // Check if there was a problem finding a client. if (result <= 0) @@ -858,9 +852,57 @@ public Action:InfectInfectCommand(client, argc) return Plugin_Handled; } - // Check if client is a human before turning into zombie. - if (InfectIsClientHuman(targets[0])) + new bool:zombiespawned = g_bZombieSpawned; + + // If zombie hasn't spawned, then make targetted player(s) mother zombies. + if (!zombiespawned) { + // Stop mother infect timer. + if (tInfect != INVALID_HANDLE) + { + KillTimer(tInfect); + tInfect = INVALID_HANDLE; + } + + // Move all clients to CT + for (new x = 1; x <= MaxClients; x++) + { + // If client isn't in-game, then stop. + if (!IsClientInGame(x)) + { + continue; + } + + // If client is dead, then stop. + if (!IsPlayerAlive(x)) + { + continue; + } + + // Switch client to CT team. + CS_SwitchTeam(x, CS_TEAM_CT); + } + + // Tell the plugin a mother zombie has spawned. + g_bZombieSpawned = true; + } + + // x = Client index. + for (new x = 0; x < result; x++) + { + // Check if client is a human before turning into zombie. + if (!InfectIsClientHuman(targets[x])) + { + // If there was only 1 player targetted, then let admin know the command was unsuccessful. + if (result == 1) + { + // Tell admin command was unsuccessful. + TranslationReplyToCommand(client, "Infect command infect unsuccessful", targetname); + } + + continue; + } + new bool:respawnoverride, bool:respawn; decl String:strRespawn[8]; @@ -874,16 +916,29 @@ public Action:InfectInfectCommand(client, argc) respawn = bool:StringToInt(strRespawn); } - // Turn client into a zombie. - InfectHumanToZombie(targets[0], _, _, respawnoverride, respawn); + // If zombie hasn't spawned, then make targetted player(s) mother zombies. + if (!zombiespawned) + { + // Turn client into a mother zombie. + InfectHumanToZombie(targets[x], _, true, respawnoverride, respawn); + + // If there was only 1 player targetted, then let admin know the outcome of the command. + if (result == 1) + { + TranslationReplyToCommand(client, "Infect command infect mother successful", targetname); + } + + continue; + } - // Tell admin command was successful. - TranslationReplyToCommand(client, "Infect command infect successful", targetname); - } - else - { - // Tell admin command was unsuccessful. - TranslationReplyToCommand(client, "Infect command infect unsuccessful", targetname); + // Turn client into a zombie. + InfectHumanToZombie(targets[x], _, false, respawnoverride, respawn); + + // If there was only 1 player targetted, then let admin know the outcome of the command. + if (result == 1) + { + TranslationReplyToCommand(client, "Infect command infect successful", targetname); + } } return Plugin_Handled; @@ -905,12 +960,6 @@ public Action:InfectHumanCommand(client, argc) return Plugin_Handled; } - if (!g_bZombieSpawned) - { - TranslationReplyToCommand(client, "Infect command zombie has not spawned"); - return Plugin_Handled; - } - decl String:target[MAX_NAME_LENGTH], String:targetname[MAX_NAME_LENGTH]; new targets[MAXPLAYERS], bool:tn_is_ml, result; @@ -918,7 +967,7 @@ public Action:InfectHumanCommand(client, argc) GetCmdArg(1, target, sizeof(target)); // Find a target. - result = ProcessTargetString(target, client, targets, sizeof(targets), COMMAND_FILTER_ALIVE | COMMAND_FILTER_NO_MULTI, targetname, sizeof(targetname), tn_is_ml); + result = ProcessTargetString(target, client, targets, sizeof(targets), COMMAND_FILTER_ALIVE , targetname, sizeof(targetname), tn_is_ml); // Check if there was a problem finding a client. if (result <= 0) @@ -927,30 +976,42 @@ public Action:InfectHumanCommand(client, argc) return Plugin_Handled; } - // Check if client is a human before turning into zombie. - if (InfectIsClientInfected(targets[0])) + // x = Client index. + for (new x = 0; x < result; x++) { - new bool:respawn, bool:protect; - decl String:strRespawn[8], String:strProtect[8]; - - // Get respawn&protect parameters - GetCmdArg(2, strRespawn, sizeof(strRespawn)); - GetCmdArg(3, strProtect, sizeof(strProtect)); - - // If parameter exists then cast it into a bool and feed it to "humanize" function. - respawn = (strRespawn[0]) ? (bool:StringToInt(strRespawn)) : false; - protect = (strProtect[0]) ? (bool:StringToInt(strProtect)) : false; - - // Turn client into a zombie. - InfectZombieToHuman(targets[0], respawn, protect); - - // Tell admin command was successful. - TranslationReplyToCommand(client, "Infect command human successful", targetname); - } - else - { - // Tell admin command was unsuccessful. - TranslationReplyToCommand(client, "Infect command human unsuccessful", targetname); + // Check if client is a human before turning into zombie. + if (InfectIsClientInfected(targets[x])) + { + new bool:respawn, bool:protect; + decl String:strRespawn[8], String:strProtect[8]; + + // Get respawn&protect parameters + GetCmdArg(2, strRespawn, sizeof(strRespawn)); + GetCmdArg(3, strProtect, sizeof(strProtect)); + + // If parameter exists then cast it into a bool and feed it to "humanize" function. + respawn = (strRespawn[0]) ? (bool:StringToInt(strRespawn)) : false; + protect = (strProtect[0]) ? (bool:StringToInt(strProtect)) : false; + + // Turn client into a zombie. + InfectZombieToHuman(targets[x], respawn, protect); + + // If there was only 1 player targetted, then let admin know the outcome of the command. + if (result == 1) + { + // Tell admin command was successful. + TranslationReplyToCommand(client, "Infect command human successful", targetname); + } + } + else + { + // If there was only 1 player targetted, then let admin know the command was unsuccessful. + if (result == 1) + { + // Tell admin command was unsuccessful. + TranslationReplyToCommand(client, "Infect command human unsuccessful", targetname); + } + } } return Plugin_Handled; diff --git a/src/zr/roundend.inc b/src/zr/roundend.inc index 1fbe7c3..c88e51f 100644 --- a/src/zr/roundend.inc +++ b/src/zr/roundend.inc @@ -234,7 +234,7 @@ bool:RoundEndGetRoundStatus(&RoundEndOutcome:outcome) new humancount; // Count valid clients. (true to only allow living clients) - ZRCountValidClients(zombiecount, humancount); + ZRCountValidClients(zombiecount, humancount, true); // If there are no clients on either teams, then stop. if (!zombiecount && !humancount) diff --git a/src/zr/volfeatures/volanticamp.inc b/src/zr/volfeatures/volanticamp.inc index 1f6b31f..bc314c1 100644 --- a/src/zr/volfeatures/volanticamp.inc +++ b/src/zr/volfeatures/volanticamp.inc @@ -33,7 +33,7 @@ enum VolTypeAnticamp Float:anticamp_interval, /** How often to trigger an action. */ Handle:anticamp_timer, /** Action timer handle. */ - VolAnticampAction:antivamp_action, /** What to do with players in anti-camp volumes */ + VolAnticampAction:anticamp_action, /** What to do with players in anti-camp volumes */ Float:anticamp_amount, /** Amount depending on action type. Usually time in seconds or damage amount. */ VolAnticampeWarningType:anticamp_warning, /** How to warn the player. */ diff --git a/src/zr/weapons/weapons.inc b/src/zr/weapons/weapons.inc index a2e0df8..6921d64 100644 --- a/src/zr/weapons/weapons.inc +++ b/src/zr/weapons/weapons.inc @@ -335,7 +335,7 @@ WeaponsOnRoundEnd() * * @param index The weapon index. */ -WeaponsClearCache(index) +stock WeaponsClearCache(index) { // Get array handle of weapon at given index. new Handle:hWeapon = GetArrayCell(arrayWeapons, index);