From 59c5e459706ae0bca8734c5c60d65d36ebcefb05 Mon Sep 17 00:00:00 2001
From: DoganGFL <gfldogan@gmail.com>
Date: Wed, 24 Jul 2019 10:10:38 +0200
Subject: [PATCH] leader2 + ZombieManager + Status: fix

---
 Status/scripting/Status.sp               |  6 +---
 ZombieManager/scripting/ZombieManager.sp | 44 +++++++++++++++++-------
 leader2/scripting/leader2.sp             | 38 ++++++++++++--------
 3 files changed, 56 insertions(+), 32 deletions(-)

diff --git a/Status/scripting/Status.sp b/Status/scripting/Status.sp
index 3c38bbf7..e0946f0a 100644
--- a/Status/scripting/Status.sp
+++ b/Status/scripting/Status.sp
@@ -38,13 +38,9 @@ public void OnPluginStart()
 
 public Action Command_Status(int client, const char[] command, int args)
 {
-	if(!client)
+	if(!client || !IsClientInGame(client))
 		return Plugin_Continue;
 
-	// hopefully fixing some dumb exploit?!
-	if(!IsClientInGame(client))
-		return Plugin_Stop;
-
 	static char sServerName[128];
 	static char sServerTags[128];
 	static char sServerAdress[128];
diff --git a/ZombieManager/scripting/ZombieManager.sp b/ZombieManager/scripting/ZombieManager.sp
index a3b87dc5..63ffee11 100644
--- a/ZombieManager/scripting/ZombieManager.sp
+++ b/ZombieManager/scripting/ZombieManager.sp
@@ -14,7 +14,7 @@ public Plugin myinfo =
 	name = "Zombie Manager",
 	author = "Dogan",
 	description = "Tools to manage testround and zombies",
-	version = "1.0.0",
+	version = "1.1.0",
 	url = ""
 };
 
@@ -22,7 +22,7 @@ public void OnPluginStart()
 {
 	g_bTestRound = false;
 	g_bAdminTestRound = false;
-
+	
 	RegAdminCmd("sm_testround", Command_Testround, ADMFLAG_GENERIC, "Toggle to enable/disable a test round.");
 
 	CreateTimer(20.0, Timer_MessageTestRound, _, TIMER_REPEAT);
@@ -30,7 +30,7 @@ public void OnPluginStart()
 	HookEvent("round_start", OnRoundStart);
 	HookEvent("player_spawn", OnClientSpawn);
 	HookEvent("player_team", OnPlayerTeam);
-
+	
 	AddMultiTargetFilter("@mzombie", Filter_Motherzombies, "Mother Zombies", false);
 	RegConsoleCmd("sm_mzombie", Command_DisplayMotherzombies, "Current Mother Zombies");
 }
@@ -56,11 +56,27 @@ public void ZR_OnClientHumanPost(int client, bool respawn, bool protect)
 	g_bMotherZM[client] = false;
 }
 
+public Action ZR_OnClientInfect(int &client, int &attacker, bool &motherInfect, bool &respawnOverride, bool &respawn)
+{
+	if(g_bTestRound)
+		return Plugin_Handled;
+
+	return Plugin_Continue;
+}
+
 public void ZR_OnClientInfected(int client, int attacker, bool motherInfect, bool respawnOverride, bool respawn)
 {
 	g_bMotherZM[client] = motherInfect;
 }
 
+public Action ZR_OnInfectCountdown()
+{
+	if(g_bTestRound)
+		return Plugin_Handled;
+
+	return Plugin_Continue;
+}
+
 public void OnClientSpawn(Event hEvent, const char[] sName, bool bDontBroadcast)
 {
 	int client = GetClientOfUserId(hEvent.GetInt("userid"));
@@ -72,10 +88,7 @@ public Action OnPlayerTeam(Event event, const char[] name, bool dontBroadcast)
 {
 	int client = GetClientOfUserId(GetEventInt(event, "userid"));
 
-	if(g_bMotherZM[client])
-	{
-		g_bMotherZM[client] = false;
-	}
+	g_bMotherZM[client] = false;
 }
 
 public bool Filter_Motherzombies(const char[] sPattern, Handle hClients, int client)
@@ -123,7 +136,7 @@ public Action Command_DisplayMotherzombies(int client, int args)
 
 public Action Command_Testround(int client, int args)
 {
-	if(GetClientTeam(client) == CS_TEAM_SPECTATOR)
+	/*if(GetClientTeam(client) == CS_TEAM_SPECTATOR)
 	{
 		ReplyToCommand(client, "[SM] Please join a Team first.");
 		return Plugin_Handled;
@@ -133,7 +146,7 @@ public Action Command_Testround(int client, int args)
 	{
 		ReplyToCommand(client, "[SM] Please respawn yourself first.");
 		return Plugin_Handled;
-	}
+	}*/
 
 	ToggleTestRound(client);
 	return Plugin_Handled;
@@ -159,12 +172,9 @@ public void ToggleTestRound(int client)
 		CPrintToChatAll("[SM] %N activated a Test Round!", client);
 		LogAction(client, -1, "\"%L\" activated a Test Round.", client);
 
-		if(ZR_IsClientHuman(client))
-			ZR_InfectClient(client);
-
 		for(int i = 1; i <= MaxClients; i++)
 		{
-			if(i != client && IsClientInGame(i) && !IsFakeClient(i))
+			if(IsClientInGame(i) && !IsFakeClient(i) && IsPlayerAlive(i) && ZR_IsClientZombie(i))
 			{
 				ZR_HumanClient(i, false, false);
 			}
@@ -172,6 +182,14 @@ public void ToggleTestRound(int client)
 	}
 }
 
+public Action CS_OnTerminateRound(float &delay, CSRoundEndReason &reason)
+{
+	if(g_bTestRound)
+		return Plugin_Handled;
+
+	return Plugin_Continue;
+}
+
 public Action ZR_OnClientRespawn(int &client, ZR_RespawnCondition &condition)
 {
     if(g_bTestRound)
diff --git a/leader2/scripting/leader2.sp b/leader2/scripting/leader2.sp
index e0cb7295..492e88ac 100644
--- a/leader2/scripting/leader2.sp
+++ b/leader2/scripting/leader2.sp
@@ -495,18 +495,23 @@ public Action Leader(int client, int args)
 			}
 			else
 			{
-				if(IsPlayerAlive(target))
+				if(!IsPlayerAlive(target))
+				{
+					ReplyToCommand(client, "[SM] The target has to be alive!");
+					return Plugin_Handled;
+				}
+				else if(ZR_IsClientZombie(target))
+				{
+					ReplyToCommand(client, "[SM] The target has to be a human!");
+					return Plugin_Handled;
+				}
+				else
 				{
 					SetLeader(target);
 					PrintToChatAll("[SM] %N is the new leader!", target);
 					PrintToChat(target, "[SM] You are now the leader! Type !leader to open up the leader menu.");
 					LeaderMenu(target);
-					return Plugin_Handled;
-				}
-				else
-				{
-					ReplyToCommand(client, "[SM] The target has to be alive!");
-					return Plugin_Handled;
+					return Plugin_Handled;				
 				}
 			}
 		}
@@ -517,18 +522,23 @@ public Action Leader(int client, int args)
 				LeaderMenu(client);
 				return Plugin_Handled;
 			}
-			if(IsPlayerAlive(client))
+			if(!IsPlayerAlive(client))
+			{
+				ReplyToCommand(client, "[SM] The target has to be alive!");
+				return Plugin_Handled;
+			}
+			else if(ZR_IsClientZombie(client))
+			{
+				ReplyToCommand(client, "[SM] The target has to be a human!");
+				return Plugin_Handled;
+			}
+			else
 			{
 				SetLeader(client);
 				PrintToChatAll("[SM] %N is the new leader!", client);
 				PrintToChat(client, "[SM] You are now the leader! Type !leader to open up the leader menu.");
 				LeaderMenu(client);
-				return Plugin_Handled;
-			}
-			else
-			{
-				ReplyToCommand(client, "[SM] The target has to be alive!");
-				return Plugin_Handled;
+				return Plugin_Handled;				
 			}
 		}
 		else