Badyx

Sistema de Elecciones

Mar 16th, 2012
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 KB | None | 0 0
  1. /* Sistema Votaciones Creado por Badyx */
  2.  
  3. /* Idea de Lore_Lungarini */
  4.  
  5. /* Modo de Uso
  6.  
  7. Usar el comando /ComenzarElecciones para empezar las elecciones
  8.  
  9. Para votar usen /Opcion1 para votar la primera opcion
  10.  
  11. o /Opcion 2 para votar la segunda opcion */
  12.  
  13. /* Includes */
  14. #include <a_samp>
  15. #include <dini>
  16.  
  17. #define Verde 0x00BF60FF
  18.  
  19. #define Rojo 0xE60000FF
  20.  
  21. new Candidato1;
  22. new Candidato2;
  23. new IniciarVotacion = 0;
  24. new yavoto[MAX_PLAYERS] = 0;
  25. forward TerminarVotacion();
  26.  
  27. #if defined FILTERSCRIPT
  28.  
  29. #else
  30.  
  31. main()
  32. {
  33. print("\n----------------------------------");
  34. print("Sistema de votaciones By Badyx");
  35. print("----------------------------------\n");
  36. }
  37.  
  38. #endif
  39.  
  40. public OnPlayerCommandText(playerid, cmdtext[])
  41. {
  42. if (strcmp("/ComenzarElecciones", cmdtext, true, 10) == 0)
  43. {
  44. if(IniciarVotacion==1) return SendClientMessage(playerid,Rojo,"La votación fué iniciada.");
  45. SetTimer("TerminarVotacion", 10000, 0);
  46. IniciarVotacion=1;
  47. SendClientMessageToAll(Verde,"|______ Hay elecciones en el gobierno____|.");
  48. SendClientMessageToAll(Verde,"Las opciones son /Opcion1 o /Opcion2.");
  49. return 1;
  50. }
  51.  
  52. if (strcmp("/Opcion1", cmdtext, true, 10) == 0)
  53. {
  54. if(IniciarVotacion==0) return SendClientMessage(playerid,Rojo,"No hay votación iniciada.");
  55. {
  56. Candidato1++;
  57. SendClientMessage(playerid,Verde,"Su voto fue contabilizado como opcion numero 1.");
  58. yavoto[playerid] = 1;
  59. return 1;
  60. }
  61. }
  62.  
  63. if (strcmp("/Opcion2", cmdtext, true, 10) == 0)
  64. {
  65. if(IniciarVotacion==0) return SendClientMessage(playerid,Rojo,"No hay votación iniciada.");
  66. {
  67. Candidato2++;
  68. SendClientMessage(playerid,Verde,"Su voto fue contabilizado como opcion numero 2.");
  69. yavoto[playerid] = 1;
  70. return 1;
  71. }
  72. }
  73.  
  74. return 0;
  75. }
  76. public TerminarVotacion()
  77. {
  78. if(Candidato1>Candidato2)
  79. {
  80. new mensaje[256];
  81. SendClientMessageToAll(Verde,"La opcion numero 1 fue la ganadora");
  82. format(mensaje,sizeof(mensaje),"La cantidad de votos que obtuvo fué %i.",Candidato1);
  83. SendClientMessageToAll(Verde,mensaje);
  84. for(new todos; todos<MAX_PLAYERS;todos++)
  85. {
  86. yavoto[todos] = 0;
  87. }
  88. }
  89. if(Candidato1<Candidato2)
  90. {
  91. new mensaje[256];
  92. SendClientMessageToAll(Verde,"La opcion numero 2 fue la ganadora.");
  93. format(mensaje,sizeof(mensaje),"La cantidad de votos que obtuvo fué %i.",Candidato2);
  94. SendClientMessageToAll(Verde,mensaje);
  95. for(new todos; todos<MAX_PLAYERS;todos++)
  96. {
  97. yavoto[todos] = 0;
  98. }
  99. }
  100. if(Candidato1==Candidato2)
  101. {
  102. new mensaje[256];
  103. SendClientMessageToAll(Verde,"El pueblo ha escogido en igual cantidad.");
  104. format(mensaje,sizeof(mensaje),"La cantidad de votos que obtuvo la opción 1 fué %i.",Candidato1);
  105. SendClientMessageToAll(Verde,mensaje);
  106. format(mensaje,sizeof(mensaje),"Y la cantidad de votos que obtuvo la opción 2 fué %i.",Candidato2);
  107. SendClientMessageToAll(Verde,mensaje);
  108. for(new todos; todos<MAX_PLAYERS;todos++)
  109. {
  110. yavoto[todos] = 0;
  111. }
  112. }
  113. Candidato1 = 0;
  114. Candidato2 = 0;
  115. IniciarVotacion=0;
  116. }
Advertisement
Add Comment
Please, Sign In to add comment