Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.26 KB | None | 0 0
  1. /* PugVoteKick.txt
  2. [en]
  3. PUG_VOTEKICK_DESC       = Vote to pick an player
  4. PUG_VOTEKICK_NEED_PLAYERS   = Need ^3%i^1 players to execute vote kick.
  5. PUG_VOTEKICK_KICK_MESSAGE   = ^3%s^1 Kicked: ^4%i^1 votes reached.
  6. PUG_VOTEKICK_NEED_MESSAGE   = ^3%s^1 voted to kick %s: Need ^4%i^1 votes to kick.
  7.  
  8. [bp]
  9. PUG_VOTEKICK_DESC       = Vote para kickar um jogador
  10. PUG_VOTEKICK_NEED_PLAYERS   = Necessario mais ^3%i^1 jogadores para usar o vote kick.
  11. PUG_VOTEKICK_KICK_MESSAGE   = ^3%s^1 Kickado: ^4%i^1 votos alcancados.
  12. PUG_VOTEKICK_NEED_MESSAGE   = ^3%s^1 votou em %s: Mais ^4%i^1 votos para kickar.
  13. */
  14.  
  15. #include <amxmodx>
  16. #include <amxmisc>
  17.  
  18. #include <PugCore>
  19. #include <PugStocks>
  20.  
  21. #define VOTEKICK_PLAYERS_MIN 3
  22.  
  23. new bool:g_Votes[MAX_PLAYERS+1][MAX_PLAYERS+1];
  24. new g_VotesNeedTeam[3];
  25.  
  26. public plugin_init()
  27. {
  28.     register_plugin("Pug Mod (Vote Kick)",PUG_VERSION,PUG_AUTHOR);
  29.    
  30.     register_dictionary("PugVotekick");
  31.    
  32.     PugRegCommand("votekick","VoteKick",ADMIN_ALL,"PUG_VOTEKICK_DESC",true);
  33. }
  34.  
  35. public client_putinserver(id)
  36. {
  37.     for(new i;i <= MaxClients;i++)
  38.     {
  39.         g_Votes[i][id] = false;
  40.         g_Votes[id][i] = false;
  41.     }
  42. }
  43.  
  44. public VoteKick(id)
  45. {
  46.     new Team[12];
  47.     new TeamIndex = get_user_team(id,Team,charsmax(Team));
  48.    
  49.     if(1 <= TeamIndex <= 2)
  50.     {
  51.         new Players[MAX_PLAYERS],PlayersCount,Player;
  52.         get_players(Players,PlayersCount,"e",Team);
  53.        
  54.         if(PlayersCount > VOTEKICK_PLAYERS_MIN)
  55.         {
  56.             new Menu = menu_create("Vote Kick:","MenuHandle");
  57.            
  58.             new Option[MAX_NAME_LENGTH];
  59.            
  60.             g_VotesNeedTeam[TeamIndex] = 0;
  61.            
  62.             for(new i;i < PlayersCount;i++)
  63.             {
  64.                 Player = Players[i];
  65.                
  66.                 if(Player != id && !access(Player,ADMIN_IMMUNITY))
  67.                 {
  68.                     get_user_name(Player,Option,charsmax(Option));             
  69.    
  70.                     menu_additem
  71.                     (
  72.                         Menu,
  73.                         Option,
  74.                         fmt("%d",Player),
  75.                         .callback = g_Votes[id][Player] ? menu_makecallback("MenuHandleDisabled") : -1
  76.                     );
  77.                    
  78.                     g_VotesNeedTeam[TeamIndex]++;
  79.                 }
  80.             }
  81.            
  82.             menu_display(id,Menu);
  83.         }
  84.         else
  85.         {
  86.             client_print_color(id,id,"%s %L",PUG_HEADER,LANG_SERVER,"PUG_VOTEKICK_NEED_PLAYERS",VOTEKICK_PLAYERS_MIN);
  87.         }
  88.     }
  89.    
  90.     return PLUGIN_HANDLED;
  91. }
  92.  
  93. public MenuHandleDisabled(id,Menu,Key)
  94. {
  95.     return ITEM_DISABLED;
  96. }
  97.  
  98. public MenuHandle(id,Menu,Key)
  99. {
  100.     if(Key != MENU_EXIT)
  101.     {
  102.         new Info[3],Option[MAX_NAME_LENGTH];
  103.         menu_item_getinfo(Menu,Key,_,Info,charsmax(Info),Option,charsmax(Option));
  104.        
  105.         new Player = str_to_num(Info);
  106.        
  107.         if(is_user_connected(Player))
  108.         {
  109.             g_Votes[id][Player] = true;    
  110.  
  111.             new VoteCount = GetVoteCount(Player);
  112.             new VotesNeed = g_VotesNeedTeam[get_user_team(id)];
  113.             new VotesLack = (VotesNeed - VoteCount);
  114.        
  115.             if(!VotesLack)
  116.             {
  117.                 server_cmd("kick #%i ^"Kicked by Vote Kick^"",get_user_userid(Player));
  118.                
  119.                 client_print_color(0,Player,"%s %L",PUG_HEADER,LANG_SERVER,"PUG_VOTEKICK_KICK_MESSAGE",Option,VotesNeed);
  120.             }
  121.             else
  122.             {
  123.                 new Name[MAX_NAME_LENGTH];
  124.                 get_user_name(id,Name,charsmax(Name));
  125.                
  126.                 client_print_color(0,id,"%s %s",PUG_HEADER,LANG_SERVER,"PUG_VOTEKICK_NEED_MESSAGE",Name,Option,VotesLack);
  127.             }
  128.         }
  129.     }
  130.    
  131.     return PLUGIN_HANDLED;
  132. }
  133.  
  134. GetVoteCount(Player)
  135. {
  136.     new Count = 0;
  137.    
  138.     for(new i;i <= MaxClients;i++)
  139.     {
  140.         if(g_Votes[i][Player])
  141.         {
  142.             Count++;
  143.         }
  144.     }
  145.    
  146.     return Count;
  147. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement