2018-11-19 21:19:26 +01:00
|
|
|
#pragma semicolon 1
|
|
|
|
|
|
|
|
#include <sourcemod>
|
|
|
|
#include <sdktools>
|
|
|
|
#include <multicolors>
|
2018-11-21 00:25:15 +01:00
|
|
|
#include <Spectate>
|
2018-11-19 21:19:26 +01:00
|
|
|
#include <zombiereloaded>
|
|
|
|
|
|
|
|
int g_iVIPClient = -1;
|
2018-11-21 17:08:31 +01:00
|
|
|
bool g_bmotherInfect = false;
|
2018-11-19 21:19:26 +01:00
|
|
|
|
|
|
|
public Plugin myinfo =
|
|
|
|
{
|
|
|
|
name = "VIP Mode",
|
|
|
|
author = "Dogan + zaCade",
|
|
|
|
description = "VIP Mode from Paranoid as Plugin",
|
2018-11-28 23:12:57 +01:00
|
|
|
version = "1.0.0",
|
2018-11-19 21:19:26 +01:00
|
|
|
url = ""
|
|
|
|
};
|
|
|
|
|
|
|
|
public void OnPluginStart()
|
|
|
|
{
|
|
|
|
HookEvent("player_death", OnPlayerDeath);
|
|
|
|
HookEvent("round_start", OnRoundStart);
|
|
|
|
HookEvent("round_end", OnRoundEnd);
|
2018-11-21 00:03:26 +01:00
|
|
|
HookEvent("player_team", OnPlayerTeam);
|
2018-11-19 21:19:26 +01:00
|
|
|
|
|
|
|
RegConsoleCmd("sm_currentvip", WhoIsVIP);
|
2018-11-21 18:06:29 +01:00
|
|
|
RegAdminCmd("sm_randomvip", PerformAdminVIPSelection, ADMFLAG_GENERIC, "Randomly chooses another alive humans as VIP");
|
2018-11-19 21:19:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public Action WhoIsVIP(int client, int args)
|
|
|
|
{
|
|
|
|
if (g_iVIPClient == -1)
|
|
|
|
{
|
|
|
|
CReplyToCommand(client, "{purple}VIP Mode:{red} There currently is no VIP!");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-09-25 14:25:27 +02:00
|
|
|
CReplyToCommand(client, "{purple}VIP Mode:{red} {white}%N{red} is the current VIP! Protect him.", g_iVIPClient);
|
2018-11-19 21:19:26 +01:00
|
|
|
}
|
2018-11-21 18:47:29 +01:00
|
|
|
return Plugin_Handled;
|
2018-11-19 21:19:26 +01:00
|
|
|
}
|
|
|
|
|
2018-11-21 16:17:45 +01:00
|
|
|
public void ZR_OnClientInfected(int client, int attacker, bool motherInfect, bool respawnOverride, bool respawn)
|
|
|
|
{
|
2018-11-21 17:08:31 +01:00
|
|
|
if(motherInfect && g_bmotherInfect == false)
|
2018-11-21 16:17:45 +01:00
|
|
|
{
|
2018-11-21 17:08:31 +01:00
|
|
|
g_bmotherInfect = true;
|
2018-11-21 16:17:45 +01:00
|
|
|
CreateTimer(5.0, SelectVIP, _, TIMER_FLAG_NO_MAPCHANGE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-19 21:19:26 +01:00
|
|
|
public Action OnRoundStart(Event event, const char[] name, bool dontBroadcast)
|
|
|
|
{
|
|
|
|
g_iVIPClient = -1;
|
2018-11-21 17:08:31 +01:00
|
|
|
g_bmotherInfect = false;
|
2018-11-19 21:19:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public Action OnRoundEnd(Event event, const char[] name, bool dontBroadcast)
|
|
|
|
{
|
|
|
|
g_iVIPClient = -1;
|
2018-11-21 17:08:31 +01:00
|
|
|
g_bmotherInfect = false;
|
2018-11-19 21:19:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public Action SelectVIP(Handle timer)
|
|
|
|
{
|
|
|
|
PerformVIPSelection(false);
|
|
|
|
}
|
|
|
|
|
2018-11-21 16:17:45 +01:00
|
|
|
public Action SlayHumans(Handle timer)
|
|
|
|
{
|
2018-11-21 18:22:19 +01:00
|
|
|
PerformCTSlay();
|
2018-11-21 16:17:45 +01:00
|
|
|
}
|
|
|
|
|
2018-11-19 21:19:26 +01:00
|
|
|
public void PerformVIPSelection(bool reselect)
|
|
|
|
{
|
|
|
|
int PotentialVIPCount;
|
|
|
|
int PotentialVIPClient[64];
|
|
|
|
|
|
|
|
for (int client = 1; client <= MaxClients; client++)
|
|
|
|
{
|
|
|
|
if (IsClientInGame(client) && IsPlayerAlive(client) && ZR_IsClientHuman(client))
|
|
|
|
{
|
2020-09-25 14:32:17 +02:00
|
|
|
if(IsFakeClient(client))
|
|
|
|
continue;
|
2020-09-26 15:24:17 +02:00
|
|
|
|
2018-11-19 21:19:26 +01:00
|
|
|
PotentialVIPClient[PotentialVIPCount] = client;
|
|
|
|
PotentialVIPCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-26 15:24:17 +02:00
|
|
|
if(PotentialVIPCount < 1)
|
|
|
|
{
|
|
|
|
CPrintToChatAll("{purple}VIP Mode:{red} Couldn't find a valid client to set as VIP. Aborting on this round.", g_iVIPClient);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-11-19 21:19:26 +01:00
|
|
|
g_iVIPClient = PotentialVIPClient[GetRandomInt(0, PotentialVIPCount - 1)];
|
|
|
|
|
2020-09-25 14:25:27 +02:00
|
|
|
CPrintToChatAll("{purple}VIP Mode:{red} {white}%N{red} is the current VIP! Protect him.", g_iVIPClient);
|
2018-11-19 21:19:26 +01:00
|
|
|
|
|
|
|
if (!reselect)
|
|
|
|
{
|
|
|
|
CPrintToChatAll("{purple}VIP Mode:{red} Everyone will die when the VIP dies!");
|
|
|
|
CPrintToChatAll("{purple}VIP Mode:{red} Everyone will die when the VIP dies!");
|
|
|
|
CPrintToChatAll("{purple}VIP Mode:{red} Everyone will die when the VIP dies!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-21 18:06:29 +01:00
|
|
|
public Action PerformAdminVIPSelection(int client, int args)
|
|
|
|
{
|
|
|
|
if(g_iVIPClient == -1)
|
|
|
|
{
|
|
|
|
CReplyToCommand(client, "{purple}VIP Mode:{red} You can't choose a VIP yet.");
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_iVIPClient = -1;
|
|
|
|
|
|
|
|
int PotentialVIPCount;
|
|
|
|
int PotentialVIPClient[64];
|
|
|
|
|
|
|
|
for (int player = 1; player <= MaxClients; player++)
|
|
|
|
{
|
|
|
|
if (IsClientInGame(player) && IsPlayerAlive(player) && ZR_IsClientHuman(player))
|
|
|
|
{
|
2020-09-26 15:24:17 +02:00
|
|
|
if(IsFakeClient(player))
|
2020-09-25 14:32:17 +02:00
|
|
|
continue;
|
2020-09-26 15:24:17 +02:00
|
|
|
|
2018-11-21 18:06:29 +01:00
|
|
|
PotentialVIPClient[PotentialVIPCount] = player;
|
|
|
|
PotentialVIPCount++;
|
|
|
|
}
|
|
|
|
}
|
2020-09-26 15:24:17 +02:00
|
|
|
|
2018-11-21 18:06:29 +01:00
|
|
|
g_iVIPClient = PotentialVIPClient[GetRandomInt(0, PotentialVIPCount - 1)];
|
|
|
|
|
2020-09-26 15:24:17 +02:00
|
|
|
ReplyToCommand(client, "[SM] You have randomly chosen another VIP.");
|
|
|
|
PrintToChatAll("[SM] %N randomly chose another VIP!", client);
|
2018-11-21 18:06:29 +01:00
|
|
|
|
2020-09-26 15:24:17 +02:00
|
|
|
CPrintToChatAll("{purple}VIP Mode:{red} {white}%N{red} is the current VIP! Protect him.", g_iVIPClient);
|
2018-11-21 18:06:29 +01:00
|
|
|
}
|
2020-09-26 15:24:17 +02:00
|
|
|
|
2018-11-21 18:47:29 +01:00
|
|
|
return Plugin_Handled;
|
2018-11-21 18:06:29 +01:00
|
|
|
}
|
|
|
|
|
2018-11-19 21:19:26 +01:00
|
|
|
public Action OnPlayerDeath(Event event, const char[] name, bool dontBroadcast)
|
|
|
|
{
|
|
|
|
int client = GetClientOfUserId(GetEventInt(event, "userid"));
|
|
|
|
|
|
|
|
if(client == g_iVIPClient)
|
|
|
|
{
|
|
|
|
g_iVIPClient = -1;
|
|
|
|
|
|
|
|
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.");
|
2018-11-21 16:17:45 +01:00
|
|
|
|
2018-11-21 18:06:29 +01:00
|
|
|
CreateTimer(2.0, SlayHumans, _, TIMER_FLAG_NO_MAPCHANGE);
|
|
|
|
}
|
2018-11-19 21:19:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void OnClientDisconnect(int client)
|
|
|
|
{
|
|
|
|
if(client == g_iVIPClient)
|
|
|
|
{
|
|
|
|
g_iVIPClient = -1;
|
|
|
|
PerformVIPSelection(true);
|
|
|
|
}
|
2018-11-21 00:03:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public Action OnPlayerTeam(Event event, const char[] name, bool dontBroadcast)
|
|
|
|
{
|
|
|
|
int client = GetClientOfUserId(GetEventInt(event, "userid"));
|
|
|
|
|
|
|
|
if(client == g_iVIPClient)
|
|
|
|
{
|
2018-11-21 00:25:15 +01:00
|
|
|
g_iVIPClient = -1;
|
|
|
|
RequestFrame(RequestFrame_Callback);
|
2018-11-21 00:03:26 +01:00
|
|
|
}
|
2018-11-21 00:25:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void OnPlayerSwitchedToSpectateByCommand(int client)
|
|
|
|
{
|
|
|
|
if(client == g_iVIPClient)
|
|
|
|
{
|
|
|
|
g_iVIPClient = -1;
|
|
|
|
RequestFrame(RequestFrame_Callback);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-21 16:17:45 +01:00
|
|
|
public void RequestFrame_Callback(int iPacked)
|
2018-11-21 00:25:15 +01:00
|
|
|
{
|
|
|
|
PerformVIPSelection(true);
|
2018-11-21 16:17:45 +01:00
|
|
|
}
|
|
|
|
|
2018-11-21 18:22:19 +01:00
|
|
|
public void PerformCTSlay()
|
2018-11-21 16:17:45 +01:00
|
|
|
{
|
2018-11-21 18:22:19 +01:00
|
|
|
for (int player = 1; player <= MaxClients; player++)
|
2018-11-21 16:17:45 +01:00
|
|
|
{
|
2018-11-21 18:22:19 +01:00
|
|
|
if (IsClientInGame(player) && IsPlayerAlive(player) && ZR_IsClientHuman(player))
|
2018-11-21 16:17:45 +01:00
|
|
|
{
|
2018-11-21 18:22:19 +01:00
|
|
|
ForcePlayerSuicide(player);
|
2018-11-21 16:17:45 +01:00
|
|
|
}
|
|
|
|
}
|
2018-11-19 21:19:26 +01:00
|
|
|
}
|