Advertisement
Chip7

[FS] FilterScript gKick v0.1 - Sistema de Votação para Kicka

Sep 13th, 2013
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 9.87 KB | None | 0 0
  1. /*
  2.   VISITE NOSSO SITE: http://www.sampknd.com/
  3.   VISITE NOSSO FACEBOOK: http://www.facebook.com/SampKnd
  4.   SAMP KND MELHOR BLOG DE SAMP DO BRASIL
  5. */
  6.  
  7. #include    <       a_samp      >
  8. #include    <       ZCMD        >
  9. #include    <       sscanf      >
  10.  
  11. /*      DEFINES         */
  12.  
  13. #define PRESSED(%0) \
  14.     (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0))) // By deregudegu
  15.  
  16.  
  17. /*  Cores   */
  18.  
  19. #define     CorSucesso      0x00FFFFFF
  20. #define     CorErro         0xFF4500FF
  21. #define     CorErroNeutro   0xFFFFFFFF
  22. #define     Branco          0xFFFFFFFF
  23. #define     Preto           0x000000FF
  24. #define     VermelhoEscuro  0xB22222FF
  25.  
  26. /*      NEW's           */
  27.  
  28. new MotivovKick[56],
  29.     Str[256],
  30.     VotosP = 0,
  31.     VotosN = 0,
  32.     SendoKickado = -1,
  33.     TimerVKick,
  34.     TempoParaKickar,
  35.  
  36. /*  Bool's  */
  37.  
  38.     bool:JaVotou[MAX_PLAYERS] = false,
  39.     bool:VotacaoIniciada = false,
  40.     bool:IniciouVotacao[MAX_PLAYERS] = false,
  41.  
  42. /*  Text's  */
  43.  
  44.     Text:TVotacao,
  45.     Text:TBox,
  46.     Text:TKickar,
  47.     Text:TNome,
  48.     Text:TAFavor,
  49.     Text:TContra,
  50.     Text:TTempo;
  51.  
  52. /*      FORWARD's       */
  53.  
  54. forward Kickar(playerid);
  55. forward vKick();
  56. forward LiberarVotacao(playerid);
  57.  
  58. /*      PUBLIC's        */
  59.  
  60. public LiberarVotacao(playerid)
  61. {
  62.     IniciouVotacao[playerid] = false;
  63.     return 1;
  64. }
  65.  
  66. public Kickar(playerid)
  67. {
  68.     // SendClientMessage(playerid, -1, #Kickado); Caso queira testar o FS sem ser kickado, altere aqui.
  69.     Kick(playerid);
  70.     return 1;
  71. }
  72.  
  73. public vKick()
  74. {
  75.     TempoParaKickar--;
  76.     //
  77.     if(TempoParaKickar == 0)
  78.     {
  79.         KillTimer(TimerVKick);
  80.         //
  81.         if(VotosP > VotosN)
  82.         {
  83.             format(Str, sizeof(Str), "AdmCmd: O Player %s foi kickado pelo administrador automático. Motivo: [Votação] %s", GetPlayerNameEx(SendoKickado), MotivovKick);
  84.             SendClientMessageToAll(VermelhoEscuro, Str);
  85.             KickP(SendoKickado);
  86.         }
  87.         if(VotosP == VotosN || VotosN > VotosP)
  88.         {
  89.             format(Str, sizeof(Str), "AdmCmd: A votação para kickar o jogador %s foi encerrada e o mesmo não foi kickado.", GetPlayerNameEx(SendoKickado));
  90.             SendClientMessageToAll(VermelhoEscuro, Str);
  91.         }
  92.         TextDrawHideForAll(TVotacao);
  93.         TextDrawHideForAll(TBox);
  94.         TextDrawHideForAll(TKickar);
  95.         TextDrawHideForAll(TNome);
  96.         TextDrawHideForAll(TAFavor);
  97.         TextDrawHideForAll(TContra);
  98.         TextDrawHideForAll(TTempo);
  99.         //
  100.         VotosP = 0;
  101.         VotosN = 0;
  102.         SendoKickado = -1;
  103.         VotacaoIniciada = false;
  104.         for(new i = 0; i < MAX_PLAYERS; i++)
  105.         {
  106.             if(IsPlayerConnected(i)) JaVotou[i] = false;
  107.         }
  108.         return 0;
  109.     }
  110.     format(Str, 256, "A FAVOR: %i", VotosP);
  111.     TextDrawSetString(TAFavor, Str);
  112.     //
  113.     format(Str, 256, "CONTRA: %i", VotosN);
  114.     TextDrawSetString(TContra, Str);
  115.     //
  116.     format(Str, 256, "%i", TempoParaKickar);
  117.     TextDrawSetString(TTempo, Str);
  118.     //
  119.     TextDrawShowForAll(TAFavor);
  120.     TextDrawShowForAll(TContra);
  121.     TextDrawShowForAll(TTempo);
  122.     return 1;
  123. }
  124.  
  125. public OnFilterScriptInit()
  126. {
  127.     print("\n--------------------------------------");
  128.     print("|     gKick Carregado com Sucesso     |");
  129.     print("--------------------------------------\n");
  130.     //
  131.     TVotacao = TextDrawCreate(515.000000, 118.000000, "VOTACAO:");
  132.     TextDrawBackgroundColor(TVotacao, 255);
  133.     TextDrawFont(TVotacao, 1);
  134.     TextDrawLetterSize(TVotacao, 0.500000, 1.000000);
  135.     TextDrawColor(TVotacao, -16711681);
  136.     TextDrawSetOutline(TVotacao, 0);
  137.     TextDrawSetProportional(TVotacao, 1);
  138.     TextDrawSetShadow(TVotacao, 1);
  139.  
  140.     TBox = TextDrawCreate(515.000000, 118.000000, "~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~");
  141.     TextDrawBackgroundColor(TBox, 255);
  142.     TextDrawFont(TBox, 1);
  143.     TextDrawLetterSize(TBox, 0.500000, 1.000000);
  144.     TextDrawColor(TBox, -16711681);
  145.     TextDrawSetOutline(TBox, 0);
  146.     TextDrawSetProportional(TBox, 1);
  147.     TextDrawSetShadow(TBox, 1);
  148.     TextDrawUseBox(TBox, 1);
  149.     TextDrawBoxColor(TBox, 1768515925);
  150.     TextDrawTextSize(TBox, 600.000000, 0.000000);
  151.  
  152.     TKickar = TextDrawCreate(529.000000, 132.000000, "KICKAR:");
  153.     TextDrawBackgroundColor(TKickar, 255);
  154.     TextDrawFont(TKickar, 1);
  155.     TextDrawLetterSize(TKickar, 0.419999, 0.799998);
  156.     TextDrawColor(TKickar, -65281);
  157.     TextDrawSetOutline(TKickar, 0);
  158.     TextDrawSetProportional(TKickar, 1);
  159.     TextDrawSetShadow(TKickar, 1);
  160.  
  161.     TNome = TextDrawCreate(557.000000, 143.000000, "MAX_PLAYER_NAME");
  162.     TextDrawAlignment(TNome, 2);
  163.     TextDrawBackgroundColor(TNome, 255);
  164.     TextDrawFont(TNome, 1);
  165.     TextDrawLetterSize(TNome, 0.250000, 0.899999);
  166.     TextDrawColor(TNome, 16777215);
  167.     TextDrawSetOutline(TNome, 0);
  168.     TextDrawSetProportional(TNome, 1);
  169.     TextDrawSetShadow(TNome, 1);
  170.  
  171.     TAFavor = TextDrawCreate(557.000000, 170.000000, "A FAVOR: 99");
  172.     TextDrawAlignment(TAFavor, 2);
  173.     TextDrawBackgroundColor(TAFavor, 255);
  174.     TextDrawFont(TAFavor, 1);
  175.     TextDrawLetterSize(TAFavor, 0.280000, 1.000000);
  176.     TextDrawColor(TAFavor, -1);
  177.     TextDrawSetOutline(TAFavor, 0);
  178.     TextDrawSetProportional(TAFavor, 1);
  179.     TextDrawSetShadow(TAFavor, 1);
  180.  
  181.     TContra = TextDrawCreate(559.000000, 182.000000, "CONTRA: 99");
  182.     TextDrawAlignment(TContra, 2);
  183.     TextDrawBackgroundColor(TContra, 255);
  184.     TextDrawFont(TContra, 1);
  185.     TextDrawLetterSize(TContra, 0.280000, 1.000000);
  186.     TextDrawColor(TContra, -1);
  187.     TextDrawSetOutline(TContra, 0);
  188.     TextDrawSetProportional(TContra, 1);
  189.     TextDrawSetShadow(TContra, 1);
  190.  
  191.     TTempo = TextDrawCreate(558.000000, 202.000000, "99");
  192.     TextDrawAlignment(TTempo, 2);
  193.     TextDrawBackgroundColor(TTempo, 255);
  194.     TextDrawFont(TTempo, 1);
  195.     TextDrawLetterSize(TTempo, 0.680000, 3.000000);
  196.     TextDrawColor(TTempo, -1094795521);
  197.     TextDrawSetOutline(TTempo, 0);
  198.     TextDrawSetProportional(TTempo, 1);
  199.     TextDrawSetShadow(TTempo, 1);
  200.     return 1;
  201. }
  202.  
  203. public OnFilterScriptExit()
  204. {
  205.     TextDrawHideForAll(TVotacao);
  206.     TextDrawHideForAll(TBox);
  207.     TextDrawHideForAll(TKickar);
  208.     TextDrawHideForAll(TNome);
  209.     TextDrawHideForAll(TAFavor);
  210.     TextDrawHideForAll(TContra);
  211.     TextDrawHideForAll(TTempo);
  212.     return 1;
  213. }
  214.  
  215. public OnPlayerDisconnect(playerid, reason)
  216. {
  217.     if(playerid == SendoKickado)
  218.     {
  219.         KillTimer(TimerVKick);
  220.         format(Str, sizeof(Str), "AdmCmd: A votação para kickar o jogador %s foi encerrada pois o mesmo saiu do jogo.", GetPlayerNameEx(SendoKickado));
  221.         SendClientMessageToAll(VermelhoEscuro, Str);
  222.         //
  223.         TextDrawHideForAll(TVotacao);
  224.         TextDrawHideForAll(TBox);
  225.         TextDrawHideForAll(TKickar);
  226.         TextDrawHideForAll(TNome);
  227.         TextDrawHideForAll(TAFavor);
  228.         TextDrawHideForAll(TContra);
  229.         TextDrawHideForAll(TTempo);
  230.         //
  231.         VotosP = 0;
  232.         VotosN = 0;
  233.         SendoKickado = -1;
  234.         VotacaoIniciada = false;
  235.         for(new i = 0; i < MAX_PLAYERS; i++)
  236.         {
  237.             if(IsPlayerConnected(i)) JaVotou[i] = false;
  238.         }
  239.     }
  240.     return 1;
  241. }
  242.  
  243. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  244. {
  245.     if(VotacaoIniciada == true)
  246.     {
  247.         if(PRESSED(KEY_ANALOG_LEFT)) // NUM 4
  248.         {
  249.             if(JaVotou[playerid] == false)
  250.             {
  251.                 VotosP++;
  252.                 SendClientMessage(playerid, CorSucesso, "O seu Voto foi computado com Sucesso, bom jogo.");
  253.                 JaVotou[playerid] = true;
  254.             }
  255.         }
  256.         if(PRESSED(KEY_ANALOG_RIGHT)) // NUM 6
  257.         {
  258.             if(JaVotou[playerid] == false)
  259.             {
  260.                 VotosN++;
  261.                 SendClientMessage(playerid, CorSucesso, "O seu Voto foi computado com Sucesso, bom jogo.");
  262.                 JaVotou[playerid] = true;
  263.             }
  264.         }
  265.     }
  266.     return 1;
  267. }
  268.  
  269. /*      Comandos's      */
  270.  
  271. CMD:vkick(playerid, params[])
  272. {
  273.     if(VotacaoIniciada == true)                             return SendClientMessage(playerid, CorErro, "Já existe uma contagem em andamento, por favor, tente novamente quando a mesma acabar.");
  274.     if(sscanf(params, "is", SendoKickado, MotivovKick))     return SendClientMessage(playerid, CorErroNeutro, "USE: /vkick [ID] [MOTIVO]");
  275.     if(!IsPlayerConnected(SendoKickado))                    return SendClientMessage(playerid, CorErro, "Este ID não está conectado.");
  276.     if(IniciouVotacao[playerid] == true)                    return SendClientMessage(playerid, CorErro, "As votações iniciadas por você precisam ter 1 minuto de intervalo entre elas.");
  277.     //
  278.     //
  279.     format(Str, 256, "{FF8C00}Foi iniciada uma votação para Kickar o jogador %s pelo motivo %s.", GetPlayerNameEx(SendoKickado), MotivovKick);
  280.     SendClientMessageToAll(Preto, Str);
  281.     SendClientMessageToAll(Preto, "{FF8C00}USE: /aprovo ou pressione NUM4 para kická-lo e /reprovo ou NUM6 para mantê-lo no game.");
  282.     //
  283.     format(Str, sizeof(Str), "%s", GetPlayerNameEx(SendoKickado));
  284.     TextDrawSetString(TNome, Str);
  285.     //
  286.     TextDrawSetString(TTempo, "20");
  287.     TempoParaKickar = 20;
  288.     //
  289.     VotosP = 0;
  290.     VotosN = 0;
  291.     //
  292.     format(Str, 256, "A FAVOR: %i", VotosP);
  293.     TextDrawSetString(TAFavor, Str);
  294.     //
  295.     format(Str, 256, "CONTRA: %i", VotosN);
  296.     TextDrawSetString(TContra, Str);
  297.     //
  298.     TextDrawShowForAll(TVotacao);
  299.     TextDrawShowForAll(TBox);
  300.     TextDrawShowForAll(TKickar);
  301.     TextDrawShowForAll(TNome);
  302.     TextDrawShowForAll(TAFavor);
  303.     TextDrawShowForAll(TContra);
  304.     TextDrawShowForAll(TTempo);
  305.     //
  306.     TimerVKick = SetTimer("vKick", 1000, true);
  307.     VotacaoIniciada = true;
  308.     IniciouVotacao[playerid] = true;
  309.     SetTimerEx("LiberarVotacao", 1000 * 60, false, "i", playerid);
  310.     return 1;
  311. }
  312.  
  313. CMD:aprovo(playerid)
  314. {
  315.     if(VotacaoIniciada == false)                return SendClientMessage(playerid, CorErro, "Nenhuma votação foi iniciada");
  316.     if(JaVotou[playerid] == true)                 return SendClientMessage(playerid, CorErro, "Só é permitido um voto por pessoa.");
  317.     JaVotou[playerid] = true;
  318.     VotosP++;
  319.     SendClientMessage(playerid, CorSucesso, "Seu voto foi contabilizado");
  320.     return 1;
  321. }
  322.  
  323. CMD:reprovo(playerid)
  324. {
  325.     if(VotacaoIniciada == false)                return SendClientMessage(playerid, CorErro, "Nenhuma votação foi iniciada");
  326.     if(JaVotou[playerid] == true)                 return SendClientMessage(playerid, CorErro, "Só é permitido um voto por pessoa.");
  327.     JaVotou[playerid] = true;
  328.     VotosN++;
  329.     SendClientMessage(playerid, CorSucesso, "Seu voto foi contabilizado");
  330.     return 1;
  331. }
  332.  
  333. /*      STOCKS's        */
  334.  
  335. stock GetPlayerNameEx(playerid)
  336. {
  337.     new pNome[24];
  338.     GetPlayerName(playerid, pNome, 24);
  339.     return pNome;
  340. }
  341.  
  342. stock KickP(playerid)
  343. {
  344.     SetTimerEx("Kickar", 1000, false, "i", playerid);
  345.     return 1;
  346. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement