From 386c806052940c9e6485f2024bb64da65805d6a5 Mon Sep 17 00:00:00 2001 From: dogan Date: Thu, 6 Aug 2020 16:55:34 +0200 Subject: [PATCH] ZombieManager: add admin command + track zm hp changes --- ZombieManager/scripting/ZombieManager.sp | 43 +++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/ZombieManager/scripting/ZombieManager.sp b/ZombieManager/scripting/ZombieManager.sp index 083a6c88..ca87a253 100644 --- a/ZombieManager/scripting/ZombieManager.sp +++ b/ZombieManager/scripting/ZombieManager.sp @@ -37,6 +37,7 @@ public void OnPluginStart() g_bAdminTestRound = false; RegAdminCmd("sm_testround", Command_Testround, ADMFLAG_GENERIC, "Toggle to enable/disable a test round."); + RegAdminCmd("sm_shield", Command_ZShield, ADMFLAG_GENERIC, "Toggle to enable/disable zombie shield."); CreateTimer(20.0, Timer_MessageTestRound, _, TIMER_REPEAT); CreateTimer(0.2, Timer_HandleHPShield, _, TIMER_REPEAT); // health_regen_interval = 0.2 @@ -86,6 +87,11 @@ public void OnPluginEnd() RemoveMultiTargetFilter("@mzombie", Filter_Motherzombies); } +public void OnMapStart() +{ + g_bShield = GetConVarBool(FindConVar("sm_zombieshield")); +} + public Action OnToggleZHP(int client, int args) { ToggleZHP(client); @@ -97,7 +103,7 @@ public void ToggleZHP(int client) g_bZHP[client] = !g_bZHP[client]; SetClientCookie(client, g_hCookieZHP, g_bZHP[client] ? "1" : ""); - CPrintToChat(client, "{lightgreen}[ZR] {yellow}%s", g_bZHP[client] ? "Zombie HP and Shield display disabled." : "Zombie HP and Shield display enabled."); + CPrintToChat(client, "{green}[ZR] {yellow}%s", g_bZHP[client] ? "Zombie HP and Shield display disabled." : "Zombie HP and Shield display enabled."); } public void OnClientCookiesCached(int client) @@ -335,6 +341,38 @@ public Action Command_Testround(int client, int args) return Plugin_Handled; } +public Action Command_ZShield(int client, int args) +{ + char sNemesis[32]; + GetConVarString(FindConVar("sm_info_message_file"), sNemesis, sizeof(sNemesis)); + bool bNemesis = StrEqual(sNemesis, "nemesis"); + + if(bNemesis) + { + ReplyToCommand(client, "[SM] Can't modify zombie shields on nemesis maps!"); + return Plugin_Handled; + } + + if(g_bShield) + { + g_bShield = false; + + ReplyToCommand(client, "[SM] Deactivated zombie shields."); + CPrintToChatAll("[SM] %N deactivated zombie shields!", client); + LogAction(client, -1, "\"%L\" deactivated zombie shields.", client); + } + else + { + g_bShield = true; + + ReplyToCommand(client, "[SM] Activated zombie shields."); + CPrintToChatAll("[SM] %N activated zombie shields!", client); + LogAction(client, -1, "\"%L\" activated zombie shields.", client); + } + + return Plugin_Handled; +} + public void ToggleTestRound(int client) { g_bAdminTestRound = !g_bAdminTestRound; @@ -404,6 +442,9 @@ public Action Timer_HandleHPShield(Handle timer) if(!IsClientInGame(i) || !IsPlayerAlive(i) || !ZR_IsClientZombie(i)) continue; + if(GetClientHealth(i) > g_iZHPMax[i]) + g_iZHPMax[i] = GetClientHealth(i); + bool bHasItem; #if defined entWatch_core_included if(g_Plugin_entWatch)