Guest User

Untitled

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