Advertisement
Graf_Spee

[PWN][FS] gKick v0.1

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