VIPMode: Add a steam ID check for past VIPs
This commit is contained in:
parent
3f7c716934
commit
0a9323996a
@ -6,6 +6,9 @@
|
|||||||
#include <Spectate>
|
#include <Spectate>
|
||||||
#include <zombiereloaded>
|
#include <zombiereloaded>
|
||||||
|
|
||||||
|
ArrayList g_aPastVIPs;
|
||||||
|
ConVar g_Cvar_CheckPastVIPs;
|
||||||
|
|
||||||
int g_iVIPClient = -1;
|
int g_iVIPClient = -1;
|
||||||
bool g_bmotherInfect = false;
|
bool g_bmotherInfect = false;
|
||||||
|
|
||||||
@ -24,6 +27,10 @@ public void OnPluginStart()
|
|||||||
HookEvent("round_start", OnRoundStart);
|
HookEvent("round_start", OnRoundStart);
|
||||||
HookEvent("round_end", OnRoundEnd);
|
HookEvent("round_end", OnRoundEnd);
|
||||||
HookEvent("player_team", OnPlayerTeam);
|
HookEvent("player_team", OnPlayerTeam);
|
||||||
|
|
||||||
|
g_aPastVIPs = new ArrayList(1, 0);
|
||||||
|
|
||||||
|
g_Cvar_CheckPastVIPs = CreateConVar("sm_vipmode_check", "1", "Toggles checking steam IDs of past VIPs", 0, false);
|
||||||
|
|
||||||
RegConsoleCmd("sm_currentvip", WhoIsVIP);
|
RegConsoleCmd("sm_currentvip", WhoIsVIP);
|
||||||
RegAdminCmd("sm_randomvip", PerformAdminVIPSelection, ADMFLAG_GENERIC, "Randomly chooses another alive humans as VIP");
|
RegAdminCmd("sm_randomvip", PerformAdminVIPSelection, ADMFLAG_GENERIC, "Randomly chooses another alive humans as VIP");
|
||||||
@ -75,14 +82,14 @@ public Action SlayHumans(Handle timer)
|
|||||||
|
|
||||||
public void PerformVIPSelection(bool reselect)
|
public void PerformVIPSelection(bool reselect)
|
||||||
{
|
{
|
||||||
int PotentialVIPCount;
|
int PotentialVIPCount = 0;
|
||||||
int PotentialVIPClient[64];
|
int PotentialVIPClient[64];
|
||||||
|
|
||||||
for (int client = 1; client <= MaxClients; client++)
|
for (int client = 1; client <= MaxClients; client++)
|
||||||
{
|
{
|
||||||
if (IsClientInGame(client) && IsPlayerAlive(client) && ZR_IsClientHuman(client))
|
if (IsClientInGame(client) && !IsFakeClient(client) && IsPlayerAlive(client) && ZR_IsClientHuman(client))
|
||||||
{
|
{
|
||||||
if(IsFakeClient(client))
|
if (g_Cvar_CheckPastVIPs.BoolValue && g_aPastVIPs.FindValue(GetSteamAccountID(client)) != -1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
PotentialVIPClient[PotentialVIPCount] = client;
|
PotentialVIPClient[PotentialVIPCount] = client;
|
||||||
@ -90,13 +97,28 @@ public void PerformVIPSelection(bool reselect)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(PotentialVIPCount < 1)
|
if(PotentialVIPCount == 0)
|
||||||
{
|
{
|
||||||
CPrintToChatAll("{purple}VIP Mode:{red} Couldn't find a valid client to set as VIP. Aborting on this round.", g_iVIPClient);
|
// Try one more time while ignoring past vips
|
||||||
return;
|
for (int client = 1; client <= MaxClients; client++)
|
||||||
|
{
|
||||||
|
if (IsClientInGame(client) && !IsFakeClient(client) && IsPlayerAlive(client) && ZR_IsClientHuman(client))
|
||||||
|
{
|
||||||
|
PotentialVIPClient[PotentialVIPCount] = client;
|
||||||
|
PotentialVIPCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(PotentialVIPCount == 0)
|
||||||
|
{
|
||||||
|
CPrintToChatAll("{purple}VIP Mode:{red} Couldn't find a valid client to set as VIP. Aborting on this round.", g_iVIPClient);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_iVIPClient = PotentialVIPClient[GetRandomInt(0, PotentialVIPCount - 1)];
|
g_iVIPClient = PotentialVIPClient[GetRandomInt(0, PotentialVIPCount - 1)];
|
||||||
|
|
||||||
|
g_aPastVIPs.Push(GetSteamAccountID(g_iVIPClient));
|
||||||
|
|
||||||
CPrintToChatAll("{purple}VIP Mode:{red} {white}%N{red} is the current VIP! Protect him.", g_iVIPClient);
|
CPrintToChatAll("{purple}VIP Mode:{red} {white}%N{red} is the current VIP! Protect him.", g_iVIPClient);
|
||||||
|
|
||||||
@ -124,11 +146,8 @@ public Action PerformAdminVIPSelection(int client, int args)
|
|||||||
|
|
||||||
for (int player = 1; player <= MaxClients; player++)
|
for (int player = 1; player <= MaxClients; player++)
|
||||||
{
|
{
|
||||||
if (IsClientInGame(player) && IsPlayerAlive(player) && ZR_IsClientHuman(player))
|
if (IsClientInGame(player) && !IsFakeClient(player) && IsPlayerAlive(player) && ZR_IsClientHuman(player))
|
||||||
{
|
{
|
||||||
if(IsFakeClient(player))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
PotentialVIPClient[PotentialVIPCount] = player;
|
PotentialVIPClient[PotentialVIPCount] = player;
|
||||||
PotentialVIPCount++;
|
PotentialVIPCount++;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user