Advertisement
Guest User

Untitled

a guest
Mar 17th, 2018
532
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.43 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], text[256];
  162. if(sscanf(params, "s[12]s[12]s[1024]", opt1, opt2, text))
  163. return SendClientMessage(playerid, -1, ""CRVENA"KORISTI: "BELA" /startvote [OPCIJA 1] [OPCIJA 2] [PREDMET GLASANJA]");
  164.  
  165. if(isnull(opt1) || isnull(opt2))
  166. return SendClientMessage(playerid, -1, ""CRVENA"Moras unijeti ime opcije");
  167.  
  168. if(isnull(text))
  169. return SendClientMessage(playerid, -1, ""CRVENA"Moras unijeti predmet glasanja!!");
  170.  
  171. if(strcmp(opt1, opt2, true) == 0)
  172. return SendClientMessage(playerid, -1, ""CRVENA"Opcija 1 i opcija 2 ne mogu biti iste!");
  173.  
  174. format(Votes[Option], 12, opt1);
  175. format(Votes[OptionTwo], 12, opt2);
  176. VoteOn = 1;
  177.  
  178. new string[144];
  179. format(string, sizeof(string), ""SPLAVA"|"BELA"__________"SPLAVA"GLASANJE JE POCELO"BELA"_________"SPLAVA"|");
  180. SendClientMessageToAll(-1, string);
  181. format(string, sizeof(string), ""CRVENA"|"BELA"~~"CRVENA"PREDMET GLASANJA"BELA"~~"CRVENA"|");
  182. SendClientMessageToAll(-1, string);
  183. format(string, sizeof(string), ""BELA"%s", text);
  184. SendClientMessageToAll(-1, string);
  185. format(string, sizeof(string), ""BELA"Opcije: "SPLAVA"%s "BELA"ili"SPLAVA"%s", Votes[Option], Votes[OptionTwo]);
  186. SendClientMessageToAll(-1, string);
  187.  
  188. return 1;
  189. }
  190. //////////////////////////////////////////////////////////////////////////////
  191. YCMD:vote(playerid, params[], help)
  192. {
  193. #pragma unused help
  194. if(!VoteOn)
  195. return SendClientMessage(playerid, -1,""CRVENA"Nije pokrenuto glasanje");
  196.  
  197. new string[144];
  198.  
  199. if(Voted[playerid])
  200. {
  201. if(VotedFor[playerid] == 1)
  202. format(string, sizeof(string), ""BELA"Vec si glasao za "SPLAVA"%s"BELA",ako hoces da promijenis glas - /cancelvote i glasaj opet.", Votes[Option]);
  203. else if(VotedFor[playerid] == 2)
  204. format(string, sizeof(string), "Vec si glasao za %s,ako hoces da promijenis glas - /cancelvote i glasaj opet.", Votes[OptionTwo]);
  205. SendClientMessage(playerid, -1, string);
  206. return 0;
  207. }
  208. if(isnull(params))
  209. {
  210. SendClientMessage(playerid, -1, "KORISTI: /vote [OPCIJA]");
  211. format(string, sizeof(string), "OPCIJE:"SPLAVA" %s "BELA"|"SPLAVA" %s", Votes[Option], Votes[OptionTwo]);
  212. SendClientMessage(playerid, -1, string);
  213. }
  214.  
  215. if(!strcmp(params, Votes[Option], true))
  216. {
  217. if(isnull(params))
  218. return 0;
  219.  
  220. format(string, sizeof(string), "Glasao si za "SPLAVA" %s.", Votes[Option]);
  221. SendClientMessage(playerid, -1, string);
  222.  
  223. Votes[VoteCount][0]++;
  224. Voted[playerid] = 1;
  225. VotedFor[playerid] = 1;
  226. }
  227. else if(!strcmp(params, Votes[OptionTwo], true))
  228. {
  229. if(isnull(params))
  230. return 0;
  231.  
  232. format(string, sizeof(string), "Glasao si za "SPLAVA" %s.", Votes[OptionTwo]);
  233. SendClientMessage(playerid, -1, string);
  234.  
  235. Votes[VoteCount][1]++;
  236. Voted[playerid] = 1;
  237. VotedFor[playerid] = 2;
  238. }
  239. return 1;
  240. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement