Guest User

[FilterScript] Sistema de Eleições

a guest
Apr 1st, 2013
400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.31 KB | None | 0 0
  1. /*VISITE NOSSO SITE: http://www.detonasamp.com/
  2.   DETONA SAMP O MELHOR BLOG DE SAMP DO BRASIL
  3. */
  4.  
  5.  
  6. //INCLUDES
  7. #include <a_samp>
  8. #include <zcmd>
  9.  
  10.  
  11. //DEFINES
  12.  
  13.  
  14. // CORES
  15. #define VERDE 0x008000C8 // {008000}
  16. #define VERMELHO 0xFF0000C8
  17. #define AMARELO 0xFFFF00C8
  18.  
  19. // NEWS'S
  20. new Votou[300], bool:Votacao;
  21. new Candidato1, Candidato2, Candidato3, Candidato4, VotoBranco;
  22. new Urna;
  23. new Text3D:Texto[MAX_PLAYERS];
  24.  
  25. public OnFilterScriptInit()
  26. {
  27.     print("\n----------------------------------------------");
  28.     print("SISTEMA DE ELEIÇÕES POR : DOUGLAS_PRT AKA RODRA");
  29.     print("----------------------------------------------\n");
  30.     return 1;
  31. }
  32.  
  33. public OnFilterScriptExit()
  34. {
  35.     return 1;
  36. }
  37.  
  38. public OnPlayerConnect(playerid)
  39. {
  40.     SendClientMessage(playerid, VERDE, "Sistema de Eleições por: {FFFFFF} Douglas_PRT aka Rodra.");
  41.     return 1;
  42. }
  43.  
  44. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  45. {
  46.     if(dialogid == 2345)
  47. {
  48.     if(response)
  49. {
  50.  
  51.     if(listitem == 0)
  52. {
  53.     SendClientMessage(playerid, AMARELO, "O seu voto foi registado. {FFFFFF}(Candidato 1).");
  54.     Candidato1++;
  55.     Votou[playerid] = 1;
  56. }
  57.  
  58.     if(listitem == 1)
  59. {
  60.     SendClientMessage(playerid, AMARELO, "O seu voto foi registado. {FFFFFF}(Candidato 2).");
  61.     Candidato2++;
  62.     Votou[playerid] = 1;
  63. }
  64.  
  65.     if(listitem == 2)
  66. {
  67.     SendClientMessage(playerid, AMARELO, "O seu voto foi registado. {FFFFFF}(Candidato 3).");
  68.     Candidato3++;
  69.     Votou[playerid] = 1;
  70. }
  71.  
  72.     if(listitem == 3)
  73. {
  74.     SendClientMessage(playerid, AMARELO, "O seu voto foi registado. {FFFFFF}(Candidato 4).");
  75.     Candidato4++;
  76.     Votou[playerid] = 1;
  77. }
  78.  
  79.     if(listitem == 4)
  80. {
  81.     SendClientMessage(playerid, AMARELO, "O seu voto foi registado. {FFFFFF}(Voto em Branco).");
  82.     Candidato4++;
  83.     Votou[playerid] = 1;
  84. }
  85. }
  86.     return 1;
  87. }
  88.     return 0;
  89. }
  90.  
  91. CMD:abrirurnas(playerid)
  92. {
  93.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, VERMELHO, "[ERRO]: Não tens permissão para efectuar este comando.");
  94.     if(Votacao == true) return SendClientMessage(playerid, VERMELHO, "[ERRO]: Já está a decorrer uma eleição.");
  95.     SendClientMessageToAll(VERMELHO, "As urnas das Eleições Presidenciais estão oficialmente abertas, dirige-te ao local de voto e digita '/votar'.");
  96.     Votacao = true;
  97.     //PICKUP + 3DLABEL
  98.     new Float:x, Float:y, Float:z;
  99.     GetPlayerPos(playerid, x, y, z);
  100.     Urna = CreateObject(3013, x, y, z, 0.0, 0.0, 0.0, 96.0);
  101.     Texto[playerid] = Create3DTextLabel("{FFFF00}Urna de Voto\n Usa /votar", 0x000000FF, x, y, z, 40.0, 0, 0);
  102.     return 1;
  103. }
  104. CMD:fecharurnas(playerid)
  105. {
  106.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, VERMELHO, "[ERRO]: Não tens permissão para efectuar este comando.");
  107.     if(Votacao == false) return SendClientMessage(playerid, VERMELHO, "[ERRO]: Não está a decorrer nenhuma votação de momento.");
  108.     new string[300];
  109.     new Total = (Candidato1 + Candidato2 + Candidato3 + Candidato4 + VotoBranco);
  110.     format(string,256, "{008000}[RESULTADOS]{FFFFFF} Candidato 1: [%d] | Candidato 2: [%d] | Candidato 3: [%d] | Candidato 4: [%d] || Total Votos: %d  | Votos em Branco: %d",Candidato1, Candidato2, Candidato3, Candidato4, Total, VotoBranco);
  111.     SendClientMessageToAll(0xFFFFFFFF, string);
  112.     // REMOVER PICKUP + 3DTEXT
  113.     DestroyObject(Urna);
  114.     Delete3DTextLabel(Texto[playerid]);
  115.     // FECHAR VOTACAO
  116.     Votacao = false;
  117.     // ANULAR TODOS OS DADOS
  118.     Candidato1 = 0;
  119.     Candidato2 = 0;
  120.     Candidato3 = 0;
  121.     Candidato4 = 0;
  122.     VotoBranco = 0;
  123.     // ACTIVAR VOTO PARA TODOS OS JOGADORES
  124.     for(new i; i < MAX_PLAYERS; i++)
  125.     if(Votou[i] == 1)
  126.     Votou[i] = 0;
  127.     return 1;
  128. }
  129. CMD:votar(playerid)
  130. {
  131.     if(Votacao == false) return SendClientMessage(playerid, VERMELHO, "[ERRO]: Não está a decorrer nenhuma votação, pelo que não podes votar.");
  132.     if(Votou[playerid] == 1) return SendClientMessage(playerid, VERMELHO, "[ERRO]: Apenas um voto por pessoa.");
  133.     new Float:X,Float:Y,Float:Z;
  134.     GetObjectPos(Urna,X,Y,Z);
  135.     if(!IsPlayerInRangeOfPoint(playerid, 2.0,X,Y,Z)) return SendClientMessage(playerid, VERMELHO, "[ERRO]: Não estás no local de votação.");
  136.     ShowPlayerDialog(playerid, 2345, DIALOG_STYLE_LIST, "Eleições | Escolha o seu Candidato:", "Candidato 1\nCandidato 2\nCandidato 3\nCandidato 4\nVoto Branco", "Votar", "Cancelar");
  137.     return 1;
  138. }
  139.  
  140. /* [FS] ELEIÇÕES PRESIDENCIAIS | CRIADO POR: DOUGLAS_PRT (NÃO RETIRE OS CREDITOS DO FS) */
Advertisement
Add Comment
Please, Sign In to add comment