From 5d458538ba4d474be412aed31cfd46ebbc03cf47 Mon Sep 17 00:00:00 2001 From: DoganGFL Date: Wed, 21 Nov 2018 18:06:29 +0100 Subject: [PATCH] fix a glitch and add sm_randomvip for admins --- VIPMode/scripting/VIPMode.sp | 48 ++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/VIPMode/scripting/VIPMode.sp b/VIPMode/scripting/VIPMode.sp index a2f0490b..14687004 100644 --- a/VIPMode/scripting/VIPMode.sp +++ b/VIPMode/scripting/VIPMode.sp @@ -7,6 +7,7 @@ #include int g_iVIPClient = -1; +int g_islay = 1; bool g_bmotherInfect = false; public Plugin myinfo = @@ -26,6 +27,7 @@ public void OnPluginStart() HookEvent("player_team", OnPlayerTeam); RegConsoleCmd("sm_currentvip", WhoIsVIP); + RegAdminCmd("sm_randomvip", PerformAdminVIPSelection, ADMFLAG_GENERIC, "Randomly chooses another alive humans as VIP"); } public Action WhoIsVIP(int client, int args) @@ -70,7 +72,7 @@ public Action SelectVIP(Handle timer) public Action SlayHumans(Handle timer) { - PerformCTSlay(); + PerformCTSlay(g_islay); } 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) { 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."); - } - CreateTimer(2.0, SlayHumans, _, TIMER_FLAG_NO_MAPCHANGE); + CreateTimer(2.0, SlayHumans, _, TIMER_FLAG_NO_MAPCHANGE); + } } public void OnClientDisconnect(int client) @@ -149,13 +183,13 @@ public void RequestFrame_Callback(int iPacked) 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); } } } \ No newline at end of file