diff --git a/VIPMode/scripting/VIPMode.sp b/VIPMode/scripting/VIPMode.sp new file mode 100644 index 00000000..2257aa18 --- /dev/null +++ b/VIPMode/scripting/VIPMode.sp @@ -0,0 +1,113 @@ +#pragma semicolon 1 + +#include +#include +#include +#include + +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); + + 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; + CreateTimer(30.0, SelectVIP, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE); +} + +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); + } +} \ No newline at end of file