diff --git a/_VIPMode/scripting/VIPMode.sp b/_VIPMode/scripting/VIPMode.sp index 17d88096..02e64df4 100644 --- a/_VIPMode/scripting/VIPMode.sp +++ b/_VIPMode/scripting/VIPMode.sp @@ -6,6 +6,9 @@ #include #include +ArrayList g_aPastVIPs; +ConVar g_Cvar_CheckPastVIPs; + int g_iVIPClient = -1; bool g_bmotherInfect = false; @@ -24,6 +27,10 @@ public void OnPluginStart() HookEvent("round_start", OnRoundStart); HookEvent("round_end", OnRoundEnd); 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); 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) { - int PotentialVIPCount; + int PotentialVIPCount = 0; int PotentialVIPClient[64]; 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; 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); - return; + // Try one more time while ignoring past vips + 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_aPastVIPs.Push(GetSteamAccountID(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++) { - 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; PotentialVIPCount++; }