Guest User

Untitled

a guest
Mar 13th, 2018
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.85 KB | None | 0 0
  1. #include zcmd
  2. #include <sscanf2>
  3. ////////////////
  4. #define BELA "{FFFFFF}"
  5. #define CRVENA "{F81414}"
  6. #define SPLAVA "{00C0FF}"
  7. ////////////////
  8. #define SCM SendClientMessage
  9. ////////////////
  10. enum voteData
  11. {
  12. Option[12],
  13. OptionTwo[12],
  14. VoteCount[2]
  15. };
  16. //////
  17. new Votes[voteData];
  18.  
  19. new
  20. VoteOn,
  21. VotedFor[MAX_PLAYERS],
  22. Voted[MAX_PLAYERS];
  23. //////
  24.  
  25. /////////////////////////////////////////////
  26. public OnPlayerConnect(playerid)
  27. {
  28. Voted[playerid] = 0;
  29. VotedFor[playerid] = 0;
  30. return 1;
  31. }
  32.  
  33.  
  34. public OnPlayerDisconnect(playerid, reason)
  35. {
  36. if(Voted[playerid])
  37. {
  38. Voted[playerid] = 0;
  39.  
  40. if(VotedFor[playerid] == 1)
  41. Votes[VoteCount][0]--;
  42. else
  43. Votes[VoteCount][1]--;
  44. VotedFor[playerid] = 0;
  45.  
  46. }
  47. return 1;
  48. }
  49.  
  50.  
  51. /////////////////////////////////////SADA SU KOMANDE///////////////////////////////////////////
  52. //////////////////////////////////////////////////////////////////////////////
  53. YCMD:votehelp(playerid, params[], help)
  54. {
  55. #pragma unused help
  56. SendClientMessage(playerid, -1, "POMOC: /vote /cancelvote /votes");
  57.  
  58. if(PlayerInfo[playerid][pAdmin] >= 4)
  59. {
  60. SendClientMessage(playerid, -1, "Admin pomoc: /startvote /endvote");
  61. }
  62. return 1;
  63. }
  64. //////////////////////////////////////////////////////////////////////////////
  65. YCMD:votes(playerid, params[], help)
  66. {
  67. #pragma unused help
  68. if(!VoteOn)
  69. return SendClientMessage(playerid, -1, ""CRVENA"Nema pokrenutog glasanja!");
  70.  
  71. new string[144];
  72.  
  73. SendClientMessage(playerid, -1, "|__________Broj glasova_________|");
  74. format(string, sizeof(string), "Opcija: "SPLAVA" %s (Glasova:"SPLAVA" %d)", Votes[Option], Votes[VoteCount][0]);
  75. SendClientMessage(playerid, -1, string);
  76.  
  77. format(string, sizeof(string), "Opcija:"SPLAVA" %s (Glasova:"SPLAVA" %d)", Votes[OptionTwo], Votes[VoteCount][1]);
  78. SendClientMessage(playerid, -1, string);
  79. return 1;
  80. }
  81. //////////////////////////////////////////////////////////////////////////////
  82. YCMD:cancelvote(playerid, params[] ,help)
  83. {
  84. #pragma unused help
  85. if(!VoteOn)
  86. return SendClientMessage(playerid, -1, ""CRVENA"Glasanje nije zapoceto");
  87.  
  88. if(!Voted[playerid])
  89. return SendClientMessage(playerid, -1, ""CRVENA"Nijesi glasao uopste,pa ne mozes povuci glas");
  90.  
  91. if(VotedFor[playerid] == 1)
  92. {
  93. Votes[VoteCount][0]--;
  94. }
  95. else if(VotedFor[playerid] == 2)
  96. {
  97. Votes[VoteCount][1]--;
  98. }
  99.  
  100. Voted[playerid] = 0;
  101. VotedFor[playerid] = 0;
  102.  
  103. SendClientMessage(playerid, -1, ""CRVENA"Povukao si glas");
  104. return 1;
  105. }
  106. //////////////////////////////////////////////////////////////////////////////
  107. YCMD:endvote(playerid, params[], help)
  108. {
  109. #pragma unused help
  110. if(!VoteOn)
  111. return SendClientMessage(playerid, -1, ""CRVENA"Glasanje nije zapoceto");
  112.  
  113. if(PlayerInfo[playerid][pAdmin] < 4)
  114. return SendClientMessage(playerid, -1, ""CRVENA"Samo A4+");
  115.  
  116. new string[144];
  117.  
  118. if(Votes[VoteCount][0] > Votes[VoteCount][1])
  119. {
  120. format(string, sizeof(string), ""SPLAVA"%s "BELA"je nadjacao protivnika.", Votes[Option]);
  121. SendClientMessageToAll(-1, string);
  122. }
  123. else if(Votes[VoteCount][0] < Votes[VoteCount][1])
  124. {
  125. format(string, sizeof(string), ""SPLAVA" %s "BELA"je nadjacao protivnika.", Votes[OptionTwo]);
  126. SendClientMessageToAll(-1, string);
  127. }
  128. else if(Votes[VoteCount][0] == Votes[VoteCount][1])
  129. {
  130. format(string, sizeof(string), "Niko nije pobijedio!!Izjednacen broj glasova ("SPLAVA"%s "BELA"| "SPLAVA"%s)", Votes[Option], Votes[OptionTwo]);
  131. SendClientMessageToAll(-1, string);
  132. }
  133.  
  134. for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
  135. {
  136. if(Voted[i])
  137. {
  138. Voted[i] = 0;
  139. VotedFor[i] = 0;
  140. }
  141. }
  142.  
  143. Votes[Option] = EOS;
  144. Votes[OptionTwo] = EOS;
  145. Votes[VoteCount][0] = 0;
  146. Votes[VoteCount][1] = 0;
  147.  
  148. VoteOn = 0;
  149. return 1;
  150. }
  151. //////////////////////////////////////////////////////////////////////////////
  152. YCMD:startvote(playerid, params[], help)
  153. {
  154. #pragma unused help
  155. if(VoteOn)
  156. return SendClientMessage(playerid, -1,""CRVENA"Glasanje je u toku");
  157.  
  158. if(PlayerInfo[playerid][pAdmin] < 4)
  159. return SendClientMessage(playerid, -1, ""CRVENA"Samo A4+");
  160.  
  161. new opt1[12], opt2[12];
  162. if(sscanf(params, "s[12]s[12]", opt1, opt2))
  163. return SendClientMessage(playerid, -1, ""CRVENA"KORISTI: /startvote [OPCIJA 1] [OPCIJA 2]");
  164.  
  165. if(isnull(opt1) || isnull(opt2))
  166. return SendClientMessage(playerid, -1, ""CRVENA"Moras unijeti ime opcije");
  167.  
  168. if(strcmp(opt1, opt2, true) == 0)
  169. return SendClientMessage(playerid, -1, ""CRVENA"Opcija 1 i opcija 2 ne mogu biti iste!");
  170.  
  171. format(Votes[Option], 12, opt1);
  172. format(Votes[OptionTwo], 12, opt2);
  173. VoteOn = 1;
  174.  
  175. new string[144];
  176. format(string, sizeof(string), ""CRVENA"|||"BELA"Glasanje je pocelo"CRVENA"|||Opcije: "SPLAVA"%s "BELA" or "SPLAVA"%s", Votes[Option], Votes[OptionTwo]);
  177. SendClientMessageToAll(-1, string);
  178.  
  179. return 1;
  180. }
  181. //////////////////////////////////////////////////////////////////////////////
  182. YCMD:vote(playerid, params[], help)
  183. {
  184. #pragma unused help
  185. if(!VoteOn)
  186. return SendClientMessage(playerid, -1,""CRVENA"Nije pokrenuto glasanje");
  187.  
  188. new string[144];
  189.  
  190. if(Voted[playerid])
  191. {
  192. if(VotedFor[playerid] == 1)
  193. format(string, sizeof(string), ""BELA"Vec si glasao za "SPLAVA"%s"BELA",ako hoces da promijenis glas - /cancelvote i glasaj opet.", Votes[Option]);
  194. else if(VotedFor[playerid] == 2)
  195. format(string, sizeof(string), "Vec si glasao za %s,ako hoces da promijenis glas - /cancelvote i glasaj opet.", Votes[OptionTwo]);
  196. SendClientMessage(playerid, -1, string);
  197. return 0;
  198. }
  199. if(isnull(params))
  200. {
  201. SendClientMessage(playerid, -1, "KORISTI: /vote [OPCIJA]");
  202. format(string, sizeof(string), "OPCIJE:"SPLAVA" %s "BELA"|"SPLAVA" %s", Votes[Option], Votes[OptionTwo]);
  203. SendClientMessage(playerid, -1, string);
  204. }
  205.  
  206. if(!strcmp(params, Votes[Option], true))
  207. {
  208. if(isnull(params))
  209. return 0;
  210.  
  211. format(string, sizeof(string), "Glasao si za "SPLAVA" %s.", Votes[Option]);
  212. SendClientMessage(playerid, -1, string);
  213.  
  214. Votes[VoteCount][0]++;
  215. Voted[playerid] = 1;
  216. VotedFor[playerid] = 1;
  217. }
  218. else if(!strcmp(params, Votes[OptionTwo], true))
  219. {
  220. if(isnull(params))
  221. return 0;
  222.  
  223. format(string, sizeof(string), "Glasao si za "SPLAVA" %s.", Votes[OptionTwo]);
  224. SendClientMessage(playerid, -1, string);
  225.  
  226. Votes[VoteCount][1]++;
  227. Voted[playerid] = 1;
  228. VotedFor[playerid] = 2;
  229. }
  230. return 1;
  231. }
Advertisement
Add Comment
Please, Sign In to add comment