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;
|
|
|
|
|
|
|
|
public Plugin myinfo =
|
|
|
|
{
|
|
|
|
name = "VIP Mode",
|
|
|
|
author = "Dogan + zaCade",
|
|
|
|
description = "VIP Mode from Paranoid as Plugin",
|
|
|
|
version = "0.1",
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
public Action WhoIsVIP(int client, int args)
|
|
|
|
{
|
|
|
|
if (g_iVIPClient == -1)
|
|
|
|
{
|
|
|
|
CReplyToCommand(client, "{purple}VIP Mode:{red} There currently is no VIP!");
|
|
|
|
return Plugin_Handled;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CReplyToCommand(client, "{purple}VIP Mode:{red} %N is the current VIP! Protect him.", g_iVIPClient);
|
|
|
|
return Plugin_Handled;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public Action OnRoundStart(Event event, const char[] name, bool dontBroadcast)
|
|
|
|
{
|
|
|
|
g_iVIPClient = -1;
|
2018-11-21 00:03:26 +01:00
|
|
|
CreateTimer(15.0, SelectVIP, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE);
|
2018-11-19 21:19:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public Action OnRoundEnd(Event event, const char[] name, bool dontBroadcast)
|
|
|
|
{
|
|
|
|
g_iVIPClient = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Action SelectVIP(Handle timer)
|
|
|
|
{
|
|
|
|
PerformVIPSelection(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
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))
|
|
|
|
{
|
|
|
|
PotentialVIPClient[PotentialVIPCount] = client;
|
|
|
|
PotentialVIPCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_iVIPClient = PotentialVIPClient[GetRandomInt(0, PotentialVIPCount - 1)];
|
|
|
|
|
|
|
|
CPrintToChatAll("{purple}VIP Mode:{red} %N is the new VIP! Protect him.", g_iVIPClient);
|
|
|
|
|
|
|
|
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!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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.");
|
|
|
|
|
|
|
|
for (int player = 1; player <= MaxClients; player++)
|
|
|
|
{
|
|
|
|
if (IsClientInGame(player) && IsPlayerAlive(player) && ZR_IsClientHuman(player))
|
|
|
|
{
|
|
|
|
ForcePlayerSuicide(player);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RequestFrame_Callback(int iPacked)
|
|
|
|
{
|
|
|
|
PerformVIPSelection(true);
|
2018-11-19 21:19:26 +01:00
|
|
|
}
|