Guest User

Untitled

a guest
May 27th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.06 KB | None | 0 0
  1. #include <sourcemod>
  2.  
  3. new bool:bBanEnabled;
  4.  
  5. public OnPluginStart()
  6.     AddCommandListener(OnSayCommand, "say");
  7.  
  8. public Action:OnSayCommand(client, const String:command[], argc)
  9.     if(GetUserAdmin(client) != INVALID_ADMIN_ID)
  10.     {
  11.         new String:sArg[128]
  12.         GetCmdArg(1, sArg, sizeof(sArg));
  13.  
  14.         if(StrEqual(sArg, "vip", false))
  15.         {
  16.             new Handle:hMenu = CreateMenu(MenuHandler);
  17.  
  18.             AddMenuItem(hMenu, "k", "Vote Kick");
  19.             AddMenuItem(hMenu, "b", "Vote Ban");
  20.             AddMenuItem(hMenu, "m", "Vote Map");
  21.  
  22.             DisplayMenu(hMenu, client, 0);
  23.         }
  24.     }
  25.  
  26. public MenuHandler(Handle:menu, MenuAction:action, param1, param2)
  27. {
  28.     if(action == MenuAction_Select)
  29.     {
  30.         new String:sInfo[32];
  31.         GetMenuItem(menu, param2, sInfo, sizeof(sInfo));
  32.  
  33.         PrintToChat(param1, "param2: %i sInfo: %s", param2, sInfo);
  34.  
  35.         new Handle:hMenu = CreateMenu(_MenuHandler);
  36.  
  37.         if(param2 < 3)
  38.         {
  39.             new String:sClient[64];
  40.  
  41.             for(new i = 1; i <= MaxClients; i++)
  42.                 if(IsClientInGame(i))
  43.                 {
  44.                     GetClientName(i, sClient, sizeof(sClient));
  45.                     AddMenuItem(hMenu, sClient, sClient);
  46.                 }
  47.  
  48.             if(param2 == 1)
  49.                 bBanEnabled = false;
  50.             else
  51.                 bBanEnabled = true;
  52.         }
  53.         else
  54.         {
  55.             new String:buffer[PLATFORM_MAX_PATH];
  56.             BuildPath(Path_SM, buffer, sizeof(buffer), "mapcycle.txt");
  57.  
  58.             new Handle:hFile = OpenFile(buffer, "r");
  59.  
  60.             if(hFile == INVALID_HANDLE)
  61.                 return;
  62.  
  63.             while(!IsEndOfFile(hFile) && ReadFileLine(hFile, buffer, sizeof(buffer)))
  64.             {
  65.                 TrimString(buffer);
  66.                 AddMenuItem(hMenu, buffer, buffer);
  67.             }
  68.         }
  69.  
  70.         DisplayMenu(hMenu, param1, 0);
  71.     }
  72.  
  73.     if(action == MenuAction_End)
  74.         CloseHandle(menu);
  75. }
  76.  
  77. public _MenuHandler(Handle:menu, MenuAction:action, param1, param2)
  78. {
  79.     if(action == MenuAction_Select)
  80.     {
  81.         new String:sInfo[32];
  82.         GetMenuItem(menu, param2, sInfo, sizeof(sInfo));
  83.  
  84.         if(IsMapValid(sInfo))
  85.             ServerCommand("sm_votemap %s", sInfo);
  86.         else
  87.         {
  88.             if(!bBanEnabled)
  89.                 ServerCommand("sm_votekick %s", sInfo);
  90.             else
  91.                 ServerCommand("sm_voteban %s", sInfo);
  92.         }
  93.     }
  94.  
  95.     if(action == MenuAction_End)
  96.         CloseHandle(menu);
  97. }
Add Comment
Please, Sign In to add comment