Guest User

Untitled

a guest
Feb 18th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 7.76 KB | None | 0 0
  1. /*******************************************************************************
  2. *                   ---=== [S]imple [V]ote [K]ick ===---                       *
  3. *                                 By Luigi96                                   *
  4. *                            -+- Version 1.0 -+-                               *
  5. *******************************************************************************/
  6.  
  7. #include <a_samp>
  8.  
  9. #define MIN_PLAYERSCORE 10000
  10. #define VOTEKICKTIME    15
  11. #define DIALOG_VOTEKICK 560
  12.  
  13. #define RED             0xFF0000FF
  14. #define YELLOW          0xFFFF00FF
  15. #define LIGHT_BLUE      0x00CCFFFF
  16.  
  17. /*******************************************************************************
  18. *                              ~[Enum & Variable]~                             *
  19. *******************************************************************************/
  20.  
  21. enum vData
  22. {
  23.     Started,
  24.     Yes,
  25.     No,
  26.     PlayerID,
  27.     Timer
  28. };
  29. new VoteKickInfo[vData],
  30.     Text:TextDrawVoteKick[5],
  31.     str[250];
  32.    
  33. forward VoteKickEnd();
  34.  
  35. /*******************************************************************************
  36. *                            ~[Callback & Function]~                           *
  37. *******************************************************************************/
  38.  
  39. public OnFilterScriptInit()
  40. {
  41.     // ============== TEXTDRAEW VOTEKICK ============== //
  42.     TextDrawVoteKick[1] = TextDrawCreate(104.000000, 161.000000, "~y~|~g~~h~A~w~s~r~E ~w~VoteKick~y~|~n~~n~~n~~n~");
  43.     TextDrawAlignment(TextDrawVoteKick[1], 2);
  44.     TextDrawBackgroundColor(TextDrawVoteKick[1], 255);
  45.     TextDrawFont(TextDrawVoteKick[1], 1);
  46.     TextDrawLetterSize(TextDrawVoteKick[1], 0.500000, 1.000000);
  47.     TextDrawColor(TextDrawVoteKick[1], -1);
  48.     TextDrawSetOutline(TextDrawVoteKick[1], 1);
  49.     TextDrawSetProportional(TextDrawVoteKick[1], 1);
  50.     TextDrawUseBox(TextDrawVoteKick[1], 1);
  51.     TextDrawBoxColor(TextDrawVoteKick[1], 85);
  52.     TextDrawTextSize(TextDrawVoteKick[1], 0.000000, 130.000000);
  53.  
  54.     TextDrawVoteKick[2] = TextDrawCreate(106.000000, 173.000000, "Vuoi ~r~Kickare ~w~Nome?");
  55.     TextDrawAlignment(TextDrawVoteKick[2], 2);
  56.     TextDrawBackgroundColor(TextDrawVoteKick[2], 255);
  57.     TextDrawFont(TextDrawVoteKick[2], 1);
  58.     TextDrawLetterSize(TextDrawVoteKick[2], 0.310000, 0.799999);
  59.     TextDrawColor(TextDrawVoteKick[2], -1);
  60.     TextDrawSetOutline(TextDrawVoteKick[2], 0);
  61.     TextDrawSetProportional(TextDrawVoteKick[2], 1);
  62.     TextDrawSetShadow(TextDrawVoteKick[2], 1);
  63.  
  64.     TextDrawVoteKick[3] = TextDrawCreate(103.000000, 186.000000, "Si (0) - No (0)");
  65.     TextDrawAlignment(TextDrawVoteKick[3], 2);
  66.     TextDrawBackgroundColor(TextDrawVoteKick[3], 255);
  67.     TextDrawFont(TextDrawVoteKick[3], 1);
  68.     TextDrawLetterSize(TextDrawVoteKick[3], 0.500000, 1.000000);
  69.     TextDrawColor(TextDrawVoteKick[3], -1);
  70.     TextDrawSetOutline(TextDrawVoteKick[3], 0);
  71.     TextDrawSetProportional(TextDrawVoteKick[3], 1);
  72.     TextDrawSetShadow(TextDrawVoteKick[3], 1);
  73.  
  74.     TextDrawVoteKick[4] = TextDrawCreate(104.000000, 196.000000, "Digita ~r~/vota~w~ per votare.");
  75.     TextDrawAlignment(TextDrawVoteKick[4], 2);
  76.     TextDrawBackgroundColor(TextDrawVoteKick[4], 255);
  77.     TextDrawFont(TextDrawVoteKick[4], 1);
  78.     TextDrawLetterSize(TextDrawVoteKick[4], 0.319999, 1.000000);
  79.     TextDrawColor(TextDrawVoteKick[4], -171);
  80.     TextDrawSetOutline(TextDrawVoteKick[4], 0);
  81.     TextDrawSetProportional(TextDrawVoteKick[4], 1);
  82.     TextDrawSetShadow(TextDrawVoteKick[4], 1);
  83.     return 1;
  84. }
  85.  
  86. public OnPlayerCommandText(playerid, cmdtext[])
  87. {
  88.     if (strcmp("/votekick", cmdtext, true, 10) == 0)
  89.     {
  90.         if(GetPlayerScore(playerid) < MIN_PLAYERSCORE)
  91.         {
  92.             ShowPlayerDialog(playerid, DIALOG_VOTEKICK+1, DIALOG_STYLE_INPUT, "{FF0000}V{FFFFFF}otekick", "{00FF00}D{FFFFFF}igita l'id del player da kickare", "Conferma", "Cancel");
  93.         }
  94.         else
  95.         {
  96.             format(str,sizeof(str),"** Errore: {FFFFFF}Devi avere %d+ di livello per poter avviare il VoteKick {FF0000}**", MIN_PLAYERSCORE);
  97.             SendClientMessage(playerid,RED,str);
  98.         }
  99.         return 1;
  100.     }
  101.     if (strcmp("/vota", cmdtext, true, 10) == 0)
  102.     {
  103.         if(VoteKickInfo[Started])
  104.         {
  105.             if(VoteKickInfo[PlayerID] != playerid)
  106.             {
  107.                 format(str,sizeof(str),"{00FF00}V{FFFFFF}uoi Kickare %s",PlayerName(VoteKickInfo[PlayerID]));
  108.                 ShowPlayerDialog(playerid, DIALOG_VOTEKICK, DIALOG_STYLE_MSGBOX, "{FF0000}V{FFFFFF}otekick", str, "Si", "No");
  109.             }
  110.             else
  111.             {
  112.                 SendClientMessage(playerid,RED,"** Errore: {FFFFFF}Non puoi votare su questo VoteKick {FF0000}**");
  113.             }
  114.         }
  115.         return 1;
  116.     }
  117.     return 0;
  118. }
  119.  
  120. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  121. {
  122.     switch(dialogid)
  123.     {
  124.         case DIALOG_VOTEKICK:
  125.         {
  126.             if(VoteKickInfo[Started])
  127.             {
  128.                 if(response)
  129.                 {
  130.                     VoteKickInfo[Yes]++;
  131.                     SendClientMessage(playerid, LIGHT_BLUE, "** VoteKick: {FFFFFF}Hai votato: {00CCFF}Si **");
  132.                 }
  133.                 else
  134.                 {
  135.                     VoteKickInfo[No]++;
  136.                     SendClientMessage(playerid, LIGHT_BLUE, "** VoteKick: {FFFFFF}Hai votato: {00CCFF}No **");
  137.                 }
  138.                 format(str,sizeof(str),"Si (%d) - No (%d)", VoteKickInfo[Yes], VoteKickInfo[No]);
  139.                 TextDrawSetString(TextDrawVoteKick[3],str);
  140.                 TextDrawShowForAll(TextDrawVoteKick[3]);
  141.             }
  142.         }
  143.         case DIALOG_VOTEKICK+1:
  144.         {
  145.             if(response)
  146.             {
  147.                 new id = strval(inputtext);
  148.                 if(!IsNumeric(inputtext) || id == INVALID_PLAYER_ID || !IsPlayerConnected(id)) return SendClientMessage(playerid,RED,"** Errore: {FFFFFF}ID/Nome non valido {FF0000}**");
  149.                 if(playerid == id) return SendClientMessage(playerid,RED,"** Errore: {FFFFFF}Non puoi far partire un Votekick su te stesso {FF0000}**");
  150.                 if(VoteKickInfo[Started] != 0) return SendClientMessage(playerid,RED,"** Errore: {FFFFFF}E' possibile far partire un VoteKick alla volta {FF0000}**");
  151.                 VoteKickInfo[PlayerID] = id;
  152.                 format(str,sizeof(str),"** %s ha iniziato un Votekick contro %s, il votekick si concluderà tra %d secondi **",PlayerName(playerid),PlayerName(id),VOTEKICKTIME);
  153.                 SendClientMessageToAll(YELLOW,str);
  154.                 TextDrawShowForAll(TextDrawVoteKick[1]);
  155.                 format(str,sizeof(str),"Vuoi ~r~Kickare ~w~%s?",PlayerName(id));
  156.                 TextDrawSetString(TextDrawVoteKick[2],str);
  157.                 TextDrawShowForAll(TextDrawVoteKick[2]);
  158.                 TextDrawSetString(TextDrawVoteKick[3],"Si (0) - No (0)");
  159.                 TextDrawShowForAll(TextDrawVoteKick[3]);
  160.                 TextDrawShowForAll(TextDrawVoteKick[4]);
  161.                 VoteKickInfo[Started] = 1;
  162.                 VoteKickInfo[Timer] = SetTimer("VoteKickEnd", VOTEKICKTIME*1000, false);
  163.             }
  164.         }
  165.     }
  166.     return 1;
  167. }
  168.  
  169. public VoteKickEnd()
  170. {
  171.     VoteKickInfo[Started] = 0;
  172.     if(VoteKickInfo[Yes] <= VoteKickInfo[No])
  173.     {
  174.         format(str,sizeof(str),"** %s non è stato kickato dal VoteKick per mancaza di voti positivi {FFFFFF}(Si[%d] - No[%d]) {E3B515}**",PlayerName(VoteKickInfo[PlayerID]),VoteKickInfo[Yes],VoteKickInfo[No]);
  175.         SendClientMessageToAll(YELLOW,str);
  176.     }
  177.     else
  178.     {
  179.         format(str,sizeof(str),"** %s è stato Kickato a causa del VoteKick {FFFFFF}(Si[%d] - No[%d]) {E3B515}**",PlayerName(VoteKickInfo[PlayerID]),VoteKickInfo[Yes],VoteKickInfo[No]);
  180.         SendClientMessageToAll(YELLOW,str);
  181.         Kick(VoteKickInfo[PlayerID]);
  182.     }
  183.     TextDrawHideForAll(TextDrawVoteKick[1]);
  184.     TextDrawHideForAll(TextDrawVoteKick[2]);
  185.     TextDrawHideForAll(TextDrawVoteKick[3]);
  186.     TextDrawHideForAll(TextDrawVoteKick[4]);
  187.     VoteKickInfo[Yes] = 0;
  188.     VoteKickInfo[No] = 0;
  189.     return 1;
  190. }
  191.  
  192. /*******************************************************************************
  193. *                               ~[Stock Utili]~                                *
  194. *******************************************************************************/
  195.  
  196. stock PlayerName(playerid)
  197. {
  198.     new Name[MAX_PLAYER_NAME];
  199.     GetPlayerName(playerid, Name, sizeof(Name));
  200.     return Name;
  201. }
  202.  
  203. stock IsNumeric(string[])
  204. {
  205.     for (new i = 0, j = strlen(string);
  206.     i < j; i++)
  207.     {
  208.         if (string[i] > '9' || string[i] < '0')
  209.         return 0;
  210.     }
  211.     return 1;
  212. }
Add Comment
Please, Sign In to add comment