Facebook
From SnowWolf, 5 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 281
  1. //===== INCLUDY =====
  2. #include <sourcemod>
  3. #include <cstrike>
  4. #include <sdktools>
  5. #include <sdkhooks>
  6.  
  7. //===== DEFINE =====
  8. #define PLUGIN_NAME             "Losowy VIP"
  9. #define PLUGIN_AUTHOR           "Hanys & ✔ SnowWolf ✔"
  10. #define PLUGIN_DESCRIPTION      "Plugin losuje osobe, ktora otrzyma vipa na jedna mape"
  11. #define PLUGIN_VERSION          "v1.1"
  12. #define PLUGIN_URL              "hanys.dispark.pl & steamcommunity.com/id/SnowWolfik"
  13.  
  14. //===== Informacje o pluginie =====//
  15. public Plugin myinfo = {
  16.     name                        = PLUGIN_NAME,
  17.     author                      = PLUGIN_AUTHOR,
  18.     description                 = PLUGIN_DESCRIPTION,
  19.     version                     = PLUGIN_VERSION,
  20.     url                         = PLUGIN_URL,
  21. };
  22.  
  23. //===== Handle =====
  24. new Handle:Random_round;
  25. new Handle:Random_player;
  26. new Rounds = 0;
  27.  
  28. //===== Public Actions & Cvary =====
  29. public OnPluginStart()
  30. {
  31.         CreateConVar("sm_randomvip", "1.0", "Losowy VIP", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
  32.        
  33.         Random_round = CreateConVar("random_round", "2", "W ktorej rundzie ma losowac losowego vip'a (Uwaga: Rozgrzewka liczona jest jako 1 runda!) 0:Losowy vip wylaczony", FCVAR_NOTIFY);
  34.         Random_player = CreateConVar("random_player", "1", "Ile osob wymaganych jest do wylosowania losowego vip'a", FCVAR_NOTIFY);
  35.        
  36.        
  37.         AutoExecConfig(true, "sm_vip_random");
  38.        
  39.         HookEvent("round_start", Event_RoundStart);
  40.         HookEvent("cs_win_panel_match", RestartRound);
  41. }
  42.  
  43. //===== Public Actions [losowanie] =====
  44. public Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
  45. {
  46.         new winner = GetRandomPlayer(3);
  47.         new g_random_round = GetConVarInt(Random_round);
  48.        
  49.         Rounds = Rounds + 1;
  50.        
  51.         if (Rounds == g_random_round)
  52.        
  53.         {
  54.                 if (winner == -1)
  55.                
  56.                 {
  57.                        
  58.                         PrintToChatAll("\x04[\x04VIP\x01] \x06Na serwerze znajduje sie za malo graczy do wylosowania losowego VIP'a\x01");
  59.                        
  60.                 }
  61.                 AddUserFlags(winner, Admin_Reservation, Admin_Custom1);
  62.                
  63.                 PrintToChatAll(" ");
  64.                 PrintToChatAll("[\x04 VIP \x01] \x01Za chwile zostanie wylosowany \x04VIP!");
  65.                 PrintToChatAll("[\x04 VIP \x01] \x01-----\x01");
  66.                 PrintToChatAll("[\x04 VIP \x01] \x01-----\x01");
  67.                 PrintToChatAll("[\x04 VIP \x01] \x01-----\x01");
  68.                 PrintToChatAll("[\x04 VIP \x01] \x01Losowym \x04VIP\x01'em zostaje...");
  69.                 PrintToChatAll("[\x04 VIP \x01] \x02%N", winner);
  70.                 PrintToChatAll("[\x04 VIP \x01] \x04Gratulujemy !");
  71.                 PrintToChatAll(" ");
  72.  
  73.  
  74.                
  75.         }
  76. }
  77.  
  78. //===== Public Actions - restart =====
  79. public Action:RestartRound(Handle:event, const String:name[], bool:dontBroadcast)
  80. {
  81.         Rounds = 0;
  82. }
  83.  
  84. //===== Ignore Admins, VIPs, GOTV =====
  85. stock GetRandomPlayer(team)
  86. {
  87.        
  88.         new g_random_player = GetConVarInt(Random_player);
  89.         new clients[MaxClients + 1], clientCount;
  90.        
  91.         for (new i = 1; i <= MaxClients; i++)
  92.         if (IsClientInGame(i) && !IsFakeClient(i) && !GetAdminFlag(GetUserAdmin(i), Admin_Reservation & Admin_Ban & Admin_Custom1))
  93.         clients[clientCount++] = i;
  94.        
  95.         if (clientCount <= g_random_player)
  96.         return -1;
  97.        
  98.         return clients[GetRandomInt(0, clientCount - 1)];
  99. }