Advertisement
Rodra

[FS] Sistema de Eleições Presidenciais/Prefeito

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