Advertisement
Guest User

nativevotes example

a guest
Apr 22nd, 2017
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.26 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <nativevotes>
  3.  
  4. int votefor;
  5.  
  6.  
  7.  
  8. // voting section
  9.  
  10.  
  11.     votefor = voteval;
  12.    
  13.     Handle vote = NativeVotes_Create(MenuHandler_VoteMaxSlots, NativeVotesType_Custom_YesNo);
  14.     NativeVotes_SetInitiator(vote, client);
  15.    
  16.     char sDetails[256];
  17.     FormatEx(sDetails, sizeof(sDetails), "Vote to change the maxslots value to %i?", votefor);
  18.     NativeVotes_SetDetails(vote, sDetails);
  19.     NativeVotes_DisplayToAll(vote, 20);
  20.    
  21.     return Plugin_Handled;
  22. }
  23.  
  24. public int MenuHandler_VoteMaxSlots(Menu menu, MenuAction action, int param1, int param2)
  25. {
  26.     switch (action)
  27.     {
  28.         case MenuAction_VoteEnd:
  29.         {
  30.             if (param1 == NATIVEVOTES_VOTE_YES)
  31.             {
  32.                 char sDetails[256];
  33.                 FormatEx(sDetails, sizeof(sDetails), "Maxslots changed to %i", votefor);
  34.                 NativeVotes_DisplayPass(menu, sDetails);
  35.                
  36.                 SetConVarInt(FindConVar("sv_maxplayers"), votefor);
  37.             }
  38.             else
  39.             {
  40.                 NativeVotes_DisplayFail(menu, NativeVotesFail_Loses);
  41.             }
  42.         }
  43.        
  44.         case MenuAction_VoteCancel:
  45.         {
  46.             if (param1 == VoteCancel_NoVotes)
  47.             {
  48.                 NativeVotes_DisplayFail(menu, NativeVotesFail_NotEnoughVotes);
  49.             }
  50.             else
  51.             {
  52.                 NativeVotes_DisplayFail(menu, NativeVotesFail_Generic);
  53.             }
  54.         }
  55.        
  56.         case MenuAction_End:
  57.         {
  58.             NativeVotes_Close(menu);
  59.         }
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement