fix a glitch and add sm_randomvip for admins
This commit is contained in:
		
							parent
							
								
									9ed4c43ced
								
							
						
					
					
						commit
						5d458538ba
					
				@ -7,6 +7,7 @@
 | 
				
			|||||||
#include <zombiereloaded>
 | 
					#include <zombiereloaded>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int g_iVIPClient = -1;
 | 
					int g_iVIPClient = -1;
 | 
				
			||||||
 | 
					int g_islay = 1;
 | 
				
			||||||
bool g_bmotherInfect = false;
 | 
					bool g_bmotherInfect = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public Plugin myinfo =
 | 
					public Plugin myinfo =
 | 
				
			||||||
@ -26,6 +27,7 @@ public void OnPluginStart()
 | 
				
			|||||||
	HookEvent("player_team", OnPlayerTeam);
 | 
						HookEvent("player_team", OnPlayerTeam);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	RegConsoleCmd("sm_currentvip", WhoIsVIP);
 | 
						RegConsoleCmd("sm_currentvip", WhoIsVIP);
 | 
				
			||||||
 | 
						RegAdminCmd("sm_randomvip", PerformAdminVIPSelection, ADMFLAG_GENERIC, "Randomly chooses another alive humans as VIP");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public Action WhoIsVIP(int client, int args)
 | 
					public Action WhoIsVIP(int client, int args)
 | 
				
			||||||
@ -70,7 +72,7 @@ public Action SelectVIP(Handle timer)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
public Action SlayHumans(Handle timer)
 | 
					public Action SlayHumans(Handle timer)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	PerformCTSlay();
 | 
						PerformCTSlay(g_islay);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public void PerformVIPSelection(bool reselect)
 | 
					public void PerformVIPSelection(bool reselect)
 | 
				
			||||||
@ -99,6 +101,38 @@ public void PerformVIPSelection(bool reselect)
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public Action PerformAdminVIPSelection(int client, int args)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						if(g_iVIPClient == -1)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							CReplyToCommand(client, "{purple}VIP Mode:{red} You can't choose a VIP yet.");
 | 
				
			||||||
 | 
							return Plugin_Handled;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							g_iVIPClient = -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							int PotentialVIPCount;
 | 
				
			||||||
 | 
							int PotentialVIPClient[64];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							for (int player = 1; player <= MaxClients; player++)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								if (IsClientInGame(player) && IsPlayerAlive(player) && ZR_IsClientHuman(player))
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									PotentialVIPClient[PotentialVIPCount] = player;
 | 
				
			||||||
 | 
									PotentialVIPCount++;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							g_iVIPClient = PotentialVIPClient[GetRandomInt(0, PotentialVIPCount - 1)];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							CPrintToChatAll("{purple}VIP Mode:{red} %N is the new VIP! Protect him.", g_iVIPClient);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							CReplyToCommand(client, "{purple}VIP Mode:{red} You have randomly chosen another VIP.");
 | 
				
			||||||
 | 
							return Plugin_Handled;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public Action OnPlayerDeath(Event event, const char[] name, bool dontBroadcast)
 | 
					public Action OnPlayerDeath(Event event, const char[] name, bool dontBroadcast)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int client = GetClientOfUserId(GetEventInt(event, "userid"));
 | 
						int client = GetClientOfUserId(GetEventInt(event, "userid"));
 | 
				
			||||||
@ -110,9 +144,9 @@ public Action OnPlayerDeath(Event event, const char[] name, bool dontBroadcast)
 | 
				
			|||||||
		CPrintToChatAll("{purple}VIP Mode:{red} The VIP died! It's over.");
 | 
							CPrintToChatAll("{purple}VIP Mode:{red} The VIP died! It's over.");
 | 
				
			||||||
		CPrintToChatAll("{purple}VIP Mode:{red} The VIP died! It's over.");
 | 
							CPrintToChatAll("{purple}VIP Mode:{red} The VIP died! It's over.");
 | 
				
			||||||
		CPrintToChatAll("{purple}VIP Mode:{red} The VIP died! It's over.");
 | 
							CPrintToChatAll("{purple}VIP Mode:{red} The VIP died! It's over.");
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	CreateTimer(2.0, SlayHumans, _, TIMER_FLAG_NO_MAPCHANGE);
 | 
							CreateTimer(2.0, SlayHumans, _, TIMER_FLAG_NO_MAPCHANGE);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public void OnClientDisconnect(int client)
 | 
					public void OnClientDisconnect(int client)
 | 
				
			||||||
@ -149,13 +183,13 @@ public void RequestFrame_Callback(int iPacked)
 | 
				
			|||||||
	PerformVIPSelection(true);
 | 
						PerformVIPSelection(true);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public void PerformCTSlay()
 | 
					public void PerformCTSlay(int slay)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	for (int player = 1; player <= MaxClients; player++)
 | 
						for (g_islay = 1; g_islay <= MaxClients; g_islay++)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		if (IsClientInGame(player) && IsPlayerAlive(player) && ZR_IsClientHuman(player))
 | 
							if (IsClientInGame(g_islay) && IsPlayerAlive(g_islay) && ZR_IsClientHuman(g_islay))
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			ForcePlayerSuicide(player);
 | 
								ForcePlayerSuicide(g_islay);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user