leader2 + ZombieManager + Status: fix

This commit is contained in:
DoganGFL 2019-07-24 10:10:38 +02:00
parent 326428915a
commit 2d53504807
3 changed files with 56 additions and 32 deletions

View File

@ -38,13 +38,9 @@ public void OnPluginStart()
public Action Command_Status(int client, const char[] command, int args) public Action Command_Status(int client, const char[] command, int args)
{ {
if(!client) if(!client || !IsClientInGame(client))
return Plugin_Continue; return Plugin_Continue;
// hopefully fixing some dumb exploit?!
if(!IsClientInGame(client))
return Plugin_Stop;
static char sServerName[128]; static char sServerName[128];
static char sServerTags[128]; static char sServerTags[128];
static char sServerAdress[128]; static char sServerAdress[128];

View File

@ -14,7 +14,7 @@ public Plugin myinfo =
name = "Zombie Manager", name = "Zombie Manager",
author = "Dogan", author = "Dogan",
description = "Tools to manage testround and zombies", description = "Tools to manage testround and zombies",
version = "1.0.0", version = "1.1.0",
url = "" url = ""
}; };
@ -22,7 +22,7 @@ public void OnPluginStart()
{ {
g_bTestRound = false; g_bTestRound = false;
g_bAdminTestRound = false; g_bAdminTestRound = false;
RegAdminCmd("sm_testround", Command_Testround, ADMFLAG_GENERIC, "Toggle to enable/disable a test round."); RegAdminCmd("sm_testround", Command_Testround, ADMFLAG_GENERIC, "Toggle to enable/disable a test round.");
CreateTimer(20.0, Timer_MessageTestRound, _, TIMER_REPEAT); CreateTimer(20.0, Timer_MessageTestRound, _, TIMER_REPEAT);
@ -30,7 +30,7 @@ public void OnPluginStart()
HookEvent("round_start", OnRoundStart); HookEvent("round_start", OnRoundStart);
HookEvent("player_spawn", OnClientSpawn); HookEvent("player_spawn", OnClientSpawn);
HookEvent("player_team", OnPlayerTeam); HookEvent("player_team", OnPlayerTeam);
AddMultiTargetFilter("@mzombie", Filter_Motherzombies, "Mother Zombies", false); AddMultiTargetFilter("@mzombie", Filter_Motherzombies, "Mother Zombies", false);
RegConsoleCmd("sm_mzombie", Command_DisplayMotherzombies, "Current Mother Zombies"); 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; 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) public void ZR_OnClientInfected(int client, int attacker, bool motherInfect, bool respawnOverride, bool respawn)
{ {
g_bMotherZM[client] = motherInfect; 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) public void OnClientSpawn(Event hEvent, const char[] sName, bool bDontBroadcast)
{ {
int client = GetClientOfUserId(hEvent.GetInt("userid")); 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")); 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) 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) 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."); ReplyToCommand(client, "[SM] Please join a Team first.");
return Plugin_Handled; return Plugin_Handled;
@ -133,7 +146,7 @@ public Action Command_Testround(int client, int args)
{ {
ReplyToCommand(client, "[SM] Please respawn yourself first."); ReplyToCommand(client, "[SM] Please respawn yourself first.");
return Plugin_Handled; return Plugin_Handled;
} }*/
ToggleTestRound(client); ToggleTestRound(client);
return Plugin_Handled; return Plugin_Handled;
@ -159,12 +172,9 @@ public void ToggleTestRound(int client)
CPrintToChatAll("[SM] %N activated a Test Round!", client); CPrintToChatAll("[SM] %N activated a Test Round!", client);
LogAction(client, -1, "\"%L\" 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++) 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); 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) public Action ZR_OnClientRespawn(int &client, ZR_RespawnCondition &condition)
{ {
if(g_bTestRound) if(g_bTestRound)

View File

@ -495,18 +495,23 @@ public Action Leader(int client, int args)
} }
else 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); SetLeader(target);
PrintToChatAll("[SM] %N is the new leader!", 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."); PrintToChat(target, "[SM] You are now the leader! Type !leader to open up the leader menu.");
LeaderMenu(target); LeaderMenu(target);
return Plugin_Handled; return Plugin_Handled;
}
else
{
ReplyToCommand(client, "[SM] The target has to be alive!");
return Plugin_Handled;
} }
} }
} }
@ -517,18 +522,23 @@ public Action Leader(int client, int args)
LeaderMenu(client); LeaderMenu(client);
return Plugin_Handled; 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); SetLeader(client);
PrintToChatAll("[SM] %N is the new leader!", 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."); PrintToChat(client, "[SM] You are now the leader! Type !leader to open up the leader menu.");
LeaderMenu(client); LeaderMenu(client);
return Plugin_Handled; return Plugin_Handled;
}
else
{
ReplyToCommand(client, "[SM] The target has to be alive!");
return Plugin_Handled;
} }
} }
else else