ZombieManager: add admin command + track zm hp changes

This commit is contained in:
dogan 2020-08-06 16:55:34 +02:00
parent 63035c3faa
commit fe6c626705

View File

@ -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)