Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.50 KB | None | 0 0
  1. #pragma semicolon 1
  2.  
  3. #define DEBUG
  4.  
  5. #define PLUGIN_AUTHOR "Mily"
  6. #define PLUGIN_VERSION "1.00"
  7.  
  8. #include <sourcemod>
  9. #include <sdktools>
  10. #include <multicolors>
  11.  
  12. #pragma newdecls required
  13.  
  14. #define DS_FLAG         ADMFLAG_CUSTOM6
  15. #define TYPE_NULL       0
  16. #define TYPE_KICK       1
  17. #define TYPE_BAN        2
  18. #define NULL_PLAYER     -2
  19.  
  20. bool voteInProgress = false;
  21. int voteTypeInProgress = TYPE_NULL;
  22. int selectedPlayer = NULL_PLAYER;
  23. int yesVotes = 0;
  24. int noVotes = 0;
  25. Handle vTimer = INVALID_HANDLE;
  26.  
  27. public Plugin myinfo =
  28. {
  29.     name = "DS - Vote Kick/Ban",
  30.     author = PLUGIN_AUTHOR,
  31.     description = "VoteKick/VoteBan for Dedicated Supporters",
  32.     version = PLUGIN_VERSION,
  33.     url = "http://www.edge-gamers.com"
  34. };
  35.  
  36. public void OnPluginStart()
  37. {
  38.     RegConsoleCmd("sm_votekick", Command_VoteKick, "Initiate a vote to kick a player.");
  39.     RegConsoleCmd("sm_voteban", Command_VoteBan, "Initiate a vote to ban a player for 30 minutes.");
  40. }
  41.  
  42. public Action Command_VoteKick(int client, any args)
  43. {
  44.     if (voteInProgress)
  45.     {
  46.         CPrintToChat(client, "{red}A vote is already in effect!");
  47.         return Plugin_Handled;
  48.     }
  49.     if (!CheckCommandAccess(client, "sm_wtfisthisarealcommandlmao", DS_FLAG))
  50.     {
  51.         CPrintToChat(client, "{red}You must be a Dedicated Supporter to use this command!");
  52.         return Plugin_Handled;
  53.     }
  54.    
  55.     voteInProgress = true;
  56.     voteTypeInProgress = TYPE_KICK;
  57.     CreatePlayerMenu(client);
  58.    
  59.     return Plugin_Handled;
  60. }
  61.  
  62. public Action Command_VoteBan(int client, any args)
  63. {
  64.     CreatePlayerMenu(client);
  65. }
  66.  
  67. public Action CreatePlayerMenu(int client)
  68. {
  69.     if(!client) return Plugin_Handled;
  70.    
  71.     int playerCount = GetClientCount(true);
  72.     char clientName[50];
  73.  
  74.     Menu menu = new Menu(Hndler_PlayerMenu);
  75.     menu.SetTitle("Select a Player:\n ");
  76.  
  77.     for (int i = 0; i < playerCount; i++)
  78.     {
  79.         if(IsClientConnected(i) && IsClientInGame(i))
  80.         {
  81.             GetClientName(i, clientName, sizeof(clientName));
  82.             AddMenuItem(menu, clientName, clientName);
  83.         }
  84.     }
  85.        
  86.     menu.ExitButton = true;
  87.     menu.Display(client, MENU_TIME_FOREVER);    
  88.    
  89.    
  90.  
  91.     return Plugin_Handled;
  92. }
  93.  
  94. public Action Command_VoteBan(int client, any args)
  95. {
  96.     CreatePlayerMenu(client);
  97. }
  98.  
  99. public Action CreateKickBanVoteMenu()
  100. {
  101.     if(!voteInProgress || !voteTypeInProgress == TYPE_NULL || selectedPlayer == NULL_PLAYER
  102.         || !IsClientInGame(selectedPlayer) || IsClientConnected(selectedPlayer)) return Plugin_Handled;
  103.    
  104.     int playerCount = GetClientCount(true);
  105.     char clientName[50];
  106.  
  107.     Menu menu = new Menu(Hndler_PlayerMenu);
  108.     menu.SetTitle("Select a Player:\n ");
  109.  
  110.     AddMenuItem(menu, clientName, clientName);
  111.  
  112.        
  113.     menu.ExitButton = true;
  114.     menu.Display(client, MENU_TIME_FOREVER);    
  115.    
  116.    
  117.  
  118.     return Plugin_Handled;
  119. }
  120.  
  121. public int Hndler_PlayerMenu( Menu menu, MenuAction action, int client, int index )
  122. {
  123.     if(action == MenuAction_Select)
  124.     {
  125.         selectedPlayer = index;
  126.         HandleSelection();
  127.     }    
  128.     else if(action == MenuAction_End)
  129.     {
  130.         delete menu;
  131.     }
  132.     return 0;
  133. }
  134.  
  135. public void HandleSelection()
  136. {
  137.     if(selectedPlayer != NULL_PLAYER && voteInProgress)
  138.     {
  139.         if(voteTypeInProgress == TYPE_KICK)
  140.         {
  141.             vTimer = CreateTimer(30.0, Timer_Vote);
  142.         }
  143.         if(voteTypeInProgress == TYPE_BAN)
  144.         {
  145.             vTimer = CreateTimer(30.0, Timer_Vote);
  146.         }
  147.     }
  148. }
  149.  
  150. public Action Timer_Vote(Handle timer, any client)
  151. {
  152.    
  153.     return Plugin_Continue;
  154. }
  155.  
  156. public void reset()
  157. {
  158.     voteInProgress = false;
  159.     voteTypeInProgress = TYPE_NULL;
  160.     selectedPlayer = NULL_PLAYER;
  161.     yesVotes = 0;
  162.     noVotes = 0;
  163.     vTimer = INVALID_HANDLE;
  164. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement