Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.21 KB | None | 0 0
  1. #include <a_samp>
  2. //----
  3. #define LARANJA             0xFF6600AA
  4. #define VERDECLARO          0x00FF0CAA
  5. #define VERDEMEDIO          0xa5b1A3AA
  6. #define BRANCO              0xFFFFFFAA
  7. #define VERMELHO            0xFF0000AA
  8. #define VERDEFRACO          0x80cf80AA
  9. //----
  10.  
  11. #define NUTZ1 1
  12.  
  13. #pragma tabsize 0
  14.  
  15. //----
  16.  
  17. enum e_votacao
  18. {
  19.     bool:iniciada,
  20.     sim,
  21.     nao,
  22.     total
  23. }
  24. new votacao[e_votacao];
  25. new votou[MAX_PLAYERS];
  26.  
  27. //----
  28. public OnPlayerCommandText(playerid, cmdtext[])
  29. {
  30.     new string[256];
  31.     if(!strcmp(cmdtext, "/votacao", true,5))
  32.     {
  33.         if(IsPlayerAdmin(playerid))
  34.         {
  35.             if(!votacao[iniciada])
  36.             {
  37.                 if(!strlen(cmdtext[6]))
  38.                     return SendClientMessage(playerid,0xFFFFFFAA, "Use: /votacao [texto]");
  39.                 SendClientMessageToAll(LARANJA,"====================================");
  40.                 format(string, sizeof string, "==> Nova Votação: %s?", cmdtext[6]);
  41.                 SendClientMessageToAll(VERDECLARO, string);
  42.                 SendClientMessageToAll(LARANJA,"Para votar:");
  43.                 SendClientMessageToAll(VERDEMEDIO, "Digite /votar e escolha uma das opções Sim e Não");
  44.                 SendClientMessageToAll(LARANJA,"====================================");
  45.                 votacao[iniciada] = true;
  46.                 votacao[sim] = 0;
  47.                 votacao[nao] = 0;
  48.                 GameTextForAll("~w~Nova ~r~votacao~w~ foi~b~ iniciada!",6000,3);
  49.                 for(new i; i <MAX_PLAYERS; i++)
  50.                 {
  51.                     votou[i] = false;
  52.                 }
  53.             } else {
  54.                 SendClientMessage(playerid,BRANCO,"Ja existe uma votação em andamento!");
  55.             }
  56.         } else {
  57.             SendClientMessage(playerid,BRANCO,"Você não tem permissão para usar este comando!");
  58.         }
  59.         return 1;
  60.     }
  61.    
  62.     public OnPlayerCommandText(playerid, cmdtext[])
  63. {
  64.     if (strcmp("/votar", cmdtext, true) == 0)
  65.     {
  66.         ShowPlayerDialog(playerid, NUTZ1, DIALOG_STYLE_LIST, "Votação - By Lucky", "Sim \nNão \nEncerrar Votação", "Selecionar", "Sair");
  67.         return 1;
  68.     }
  69.     return 0;
  70. }
  71.  
  72. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  73. {
  74.     if(response)
  75.     {
  76.         if(dialogid == NUTZ1) // GPS Dialog
  77.         {
  78.         if(listitem == 0) // Sim
  79.         {
  80.         if(votacao[iniciada] && !votou[playerid])
  81.         {
  82.             SendClientMessage(playerid,LARANJA, "Seu voto foi enviado com sucesso!");
  83.             votacao[sim]++;
  84.             votacao[total]++;
  85.             votou[playerid] = true;
  86.             return 1;
  87.         }
  88.         }
  89.             else if(listitem == 1) // Não
  90.             {
  91.         if(votacao[iniciada] && !votou[playerid])
  92.         {
  93.             SendClientMessage(playerid,LARANJA, "Seu voto foi enviado com sucesso!");
  94.             votacao[nao]++;
  95.             votacao[total]++;
  96.             votou[playerid] = true;
  97.             return 1;
  98.         }
  99.             }
  100.             else if(listitem == 2) // Encerrar Votação
  101.             {
  102. if(IsPlayerAdmin(playerid))
  103.         {
  104.             if(votacao[iniciada])
  105.             {
  106.                 SendClientMessageToAll(LARANJA,"====================================");
  107.                 SendClientMessageToAll(LARANJA, "==> Votacão encerrada! <<==");
  108.                 format(string, sizeof string, "> %d jogador(es) concordaram com a pergunta.", votacao[sim]);
  109.                 SendClientMessageToAll(VERDEMEDIO,string);
  110.                 format(string, sizeof string, "> %d jogador(es) discordaram com a pergunta.", votacao[nao]);
  111.                 SendClientMessageToAll(VERDEMEDIO, string);
  112.                 format(string, sizeof string, "> Esta votação teve %d votos!",votacao[total]);
  113.                 SendClientMessageToAll(BRANCO, string);
  114.                 if(votacao[sim] == votacao[nao])
  115.                 {
  116.                     SendClientMessageToAll(VERMELHO, "==> Houve um empate!");
  117.                 } else if(votacao[sim] > votacao[nao])
  118.                 {
  119.                     SendClientMessageToAll(VERMELHO, "==> A maioria CONCORDA com a pergunta.");
  120.                 } else if(votacao[sim] < votacao[nao])
  121.                 {
  122.                     SendClientMessageToAll(VERMELHO, "==> A maioria DISCORDA com a pergunta.");
  123.                 }
  124.                 SendClientMessageToAll(LARANJA,"====================================");
  125.                 GameTextForAll("~r~Votacao~w~ foi~r~ encerrada!",6000,3);
  126.                 votacao[iniciada] = false;
  127.                 votacao[sim] = 0;
  128.                 votacao[nao] = 0;
  129.                 votacao[total] = 0;
  130.                 for(new i; i <MAX_PLAYERS; i++)
  131.                 {
  132.                     votou[i] = false;
  133.                 }
  134.             } else {
  135.                 SendClientMessage(playerid,BRANCO, "Nenhuma votação foi criada!");
  136.             }
  137.         } else {
  138.             SendClientMessage(playerid,BRANCO, "Você não tem permissão para usar este comando!");
  139.         }
  140.         return 1;
  141.       }
  142.         }
  143.     }
  144.     return 1;
  145. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement