Advertisement
toribio

toribio

Mar 18th, 2009
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.20 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. enum e_votacao
  4. {
  5.     bool:iniciada,
  6.     sim,
  7.     nao,
  8.     bool:votou[MAX_PLAYERS]
  9. }
  10.  
  11. new votacao[e_votacao];
  12.  
  13. public OnFilterScriptInit()
  14. {
  15.     print("==>> Filter Script de Votacao! <<==");
  16.     print("==>> Criado por [CCV]saalada[] <<==");
  17.     print("==>>  Ajuda de Flavio Toribio  <<==");
  18.     print("==>>     Versao 0.1 BETA       <<==");
  19.     print("==>>   www.ccvteam.com/forum   <<==");
  20.     return 1;
  21. }
  22.  
  23. public OnPlayerCommandText(playerid, cmdtext[])
  24. {
  25.     new string[256];
  26.     if(!strcmp(cmdtext, "/votacao", true, 8))
  27.     {
  28.         if(IsPlayerAdmin(playerid))
  29.         {
  30.             if(!votacao[iniciada])
  31.             {
  32.                 if(!cmdtext[9])
  33.                 {
  34.                     SendClientMessage(playerid, 0xFFFFFFAA, "Use: /votacao [pergunta]");
  35.                     return 1;
  36.                 }
  37.                 format(string, sizeof string, "==> Votaco iniciada: %s ?", cmdtext[10]);
  38.                 SendClientMessageToAll(0xFFFFFFAA, string);
  39.                 SendClientMessageToAll(0xFFF000AA, "> Se voc concorda digite: /sim");
  40.                 SendClientMessageToAll(0xFFF000AA, "> Se voc discorda digite: /nao");
  41.                 votacao[iniciada] = true;
  42.                 votacao[sim] = 0;
  43.                 votacao[nao] = 0;
  44.                 for(new i; i < MAX_PLAYERS; i++)
  45.                     votacao[votou[i]] = false;
  46.             } else {
  47.                 SendClientMessage(playerid, 0xFFFFFFAA,"Ja existe uma votacao em andamento!");
  48.             }
  49.         } else {
  50.             SendClientMessage(playerid, 0xFFFFFFAA,"Voc no tem permisso para usar este comando!");
  51.         }
  52.         return 1;
  53.     }
  54.     if(!strcmp(cmdtext, "/sim", true))
  55.     {
  56.         if(votacao[iniciada] && !votacao[votou[playerid]])
  57.         {
  58.             SendClientMessage(playerid, 0xFFFFFFAA, "Seu voto foi computado com sucesso!");
  59.             votacao[sim]++;
  60.             votacao[votou[playerid]] = true;
  61.             return 1;
  62.         }
  63.         return 0;
  64.     }
  65.     if(!strcmp(cmdtext, "/nao", true))
  66.     {
  67.         if(votacao[iniciada] && !votacao[votou[playerid]])
  68.         {
  69.             SendClientMessage(playerid, 0xFFFFFFAA, "Seu voto foi computado com sucesso!");
  70.             votacao[nao]++;
  71.             votacao[votou[playerid]] = true;
  72.             return 1;
  73.         }
  74.         return 0;
  75.     }
  76.     if(!strcmp(cmdtext, "/encerrar", true))
  77.     {
  78.         if(IsPlayerAdmin(playerid))
  79.         {
  80.             if(votacao[iniciada])
  81.             {
  82.                 SendClientMessageToAll(0xFFFFFFAA, "==> Votaco encerrada!");
  83.                 format(string, sizeof string, "> %d pessoas concordaram com a pergunta;", votacao[sim]);
  84.                 SendClientMessageToAll(0xFFF000AA,string);
  85.                 format(string, sizeof string, "> %d pessoas discordaram com a pergunta;", votacao[nao]);
  86.                 SendClientMessageToAll(0xFFF000AA, string);
  87.                 if(votacao[sim] == votacao[nao])
  88.                 {
  89.                     SendClientMessageToAll(0xFF0000AA, "==> Houve um empate!");
  90.                 } else if(votacao[sim] > votacao[nao])
  91.                 {
  92.                     SendClientMessageToAll(0xFF0000AA, "==> A maioria CONCORDA com a  pergunta.");
  93.                 } else if(votacao[sim] < votacao[nao])
  94.                 {
  95.                     SendClientMessageToAll(0xFF0000AA, "==> A maioria DISCORDA com a  pergunta.");
  96.                 }
  97.                 votacao[iniciada] = false;
  98.                 votacao[sim] = 0;
  99.                 votacao[nao] = 0;
  100.                 for(new i; i < MAX_PLAYERS; i++)
  101.                     votacao[votou[i]] = false;
  102.             } else {
  103.                 SendClientMessage(playerid, 0xFFFFFFAA, "Nenhuma votacao criada!");
  104.             }
  105.         } else {
  106.             SendClientMessage(playerid, 0xFFFFFFAA, "Voc no tem permisso para usar este comando!");
  107.         }
  108.         return 1;
  109.     }
  110.     return 0;
  111. }
  112.  
  113. public OnPlayerConnect(playerid)
  114. {
  115.     votacao[votou[playerid]] = false;
  116.     return 1;
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement