Guest User

votekick

a guest
Sep 2nd, 2011
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.13 KB | None | 0 0
  1. /*
  2. ================================================================================
  3. Phanto's Script
  4. ________________________________________________________________________________
  5. •Skripta: PVoteKick •Skripter: Phanto90
  6. •Tip: FS •Velicina datoteke: 6 Kb
  7. •Linije: 261 •Verzija: 1.0v
  8. ________________________________________________________________________________
  9. * Opis *
  10.  
  11. Ovo je jednostavna filterskripta.To je sistem za glasanje da se nekoga kicka
  12. (izbaci) sa servera.
  13. ________________________________________________________________________________
  14. */
  15. //===============INCLUDE
  16. #include <a_samp>
  17. //===============COLORI
  18. #define COLOR_ERROR 0xCB544EFF
  19. #define COLOR_OK 0x50C94EFF
  20. //===============0.3c
  21. #define RED "{C14124}"
  22. #define GREY "{BBBBBB}"
  23. #define GREEN "{60B149}"
  24. #define none "{B35349}"
  25. //===============DIALOG
  26. #define DIALOG_VOTEKICK 1945
  27. //===============VAR
  28. new nput2[128];
  29. new razlog[128];
  30. new rdialog;
  31. new bool:IsVoteKickStarted,
  32. bool:HasPlayerVoted[MAX_PLAYERS];
  33.  
  34. new PlayerToKick=-1,
  35. Yes,No,
  36. seconds=60;
  37.  
  38. new string[135],
  39. name[24],
  40. name2[24];
  41.  
  42. new Text: Pozadina,
  43. Text: VoteKickTitle,
  44. Text: VoteKickName,
  45. Text: VoteKickVote,
  46. Text: VoteKickTime;
  47. //============================================================ONFILTERSCRIPTINIT
  48. public OnFilterScriptInit()
  49. {
  50. format(string, sizeof(string), "|||");
  51. Pozadina = TextDrawCreate(493.000000, 230.000000, string);
  52. TextDrawBackgroundColor(Pozadina, 0);
  53. TextDrawFont(Pozadina, 1);
  54. TextDrawLetterSize(Pozadina, 0.500000, 6.099999);
  55. TextDrawColor(Pozadina, 0);
  56. TextDrawSetOutline(Pozadina, 0);
  57. TextDrawSetProportional(Pozadina, 1);
  58. TextDrawSetShadow(Pozadina, 1);
  59. TextDrawUseBox(Pozadina, 1);
  60. TextDrawBoxColor(Pozadina, 1010580580);
  61. TextDrawTextSize(Pozadina, 616.000000, 0.000000);
  62.  
  63. VoteKickTitle = TextDrawCreate(497.000000, 211.000000, "~g~-->~r~Kick~g~<--");
  64. TextDrawBackgroundColor(VoteKickTitle, 255);
  65. TextDrawFont(VoteKickTitle, 2);
  66. TextDrawLetterSize(VoteKickTitle, 0.660000, 2.599999);
  67. TextDrawColor(VoteKickTitle, -1);
  68. TextDrawSetOutline(VoteKickTitle, 1);
  69. TextDrawSetProportional(VoteKickTitle, 1);
  70.  
  71. VoteKickVote = TextDrawCreate(555.000000, 254.000000, "~g~~h~Da~w~: 0 ~r~Ne~w~: 0");
  72. TextDrawAlignment(VoteKickVote, 2);
  73. TextDrawBackgroundColor(VoteKickVote, 255);
  74. TextDrawFont(VoteKickVote, 2);
  75. TextDrawLetterSize(VoteKickVote, 0.390000, 2.199999);
  76. TextDrawColor(VoteKickVote, -1);
  77. TextDrawSetOutline(VoteKickVote, 1);
  78. TextDrawSetProportional(VoteKickVote, 1);
  79.  
  80. VoteKickTime = TextDrawCreate(601.000000, 273.000000, "60");
  81. TextDrawBackgroundColor(VoteKickTime, 255);
  82. TextDrawFont(VoteKickTime, 2);
  83. TextDrawLetterSize(VoteKickTime, 0.250000, 1.500000);
  84. TextDrawColor(VoteKickTime, -926365441);
  85. TextDrawSetOutline(VoteKickTime, 1);
  86. TextDrawSetProportional(VoteKickTime, 1);
  87.  
  88. VoteKickName = TextDrawCreate(555.000000, 241.000000, "Player_Name");
  89. TextDrawAlignment(VoteKickName, 2);
  90. TextDrawBackgroundColor(VoteKickName, 255);
  91. TextDrawFont(VoteKickName, 1);
  92. TextDrawLetterSize(VoteKickName, 0.280000, 1.300000);
  93. TextDrawColor(VoteKickName, -1);
  94. TextDrawSetOutline(VoteKickName, 1);
  95. TextDrawSetProportional(VoteKickName, 1);
  96. return 1;
  97. }
  98. //===============================================================ONPLAYERCONNECT
  99. public OnPlayerConnect(playerid)
  100. {
  101. if(IsVoteKickStarted == true)
  102. {
  103. TextDrawShowForPlayer(playerid, Pozadina);
  104. TextDrawShowForPlayer(playerid, VoteKickTitle);
  105. TextDrawShowForPlayer(playerid, VoteKickName);
  106. TextDrawShowForPlayer(playerid, VoteKickVote);
  107. TextDrawShowForPlayer(playerid, VoteKickTime);
  108. return 1;
  109. }
  110. return 1;
  111. }
  112. //===========================================================ONPLAYERCOMMANDTEXT
  113. public OnPlayerCommandText(playerid, cmdtext[])
  114. {
  115. if(!strcmp("/glasaj", cmdtext, true))
  116. {
  117. if(IsVoteKickStarted == true) return SendClientMessage(playerid, COLOR_ERROR,"[Greska:] {BBBBBB}Jedno glasanje je upravo u toku, pricekaj da zavrsi pa zapocni novo glasanje.");
  118. ShowPlayerDialog(playerid, DIALOG_VOTEKICK, DIALOG_STYLE_INPUT, "{C14124}G{BBBBBB}lasanje", "{BBBBBB}Upisi {C14124}ID{BBBBBB} ili {C14124}Ime{BBBBBB} igraca kojeg zelis izbaciti.", "VoteKick", "Cancel");
  119. return 1;
  120. }
  121. return 1;
  122. }
  123. //============================================================ONPLAYERDISCONNECT
  124. public OnPlayerDisconnect(playerid)
  125. {
  126. if(PlayerToKick == playerid)
  127. {
  128. if(seconds > 0)
  129. {
  130. GetPlayerName(playerid, name, sizeof(name));
  131. format(string, sizeof(string), "{C14124}%s{BBBBBB} je napustio server pa je glasanje automatski prekinuto.", name);
  132. SendClientMessageToAll(COLOR_OK, string);
  133. Yes=0,No=0,PlayerToKick=-1, seconds=60, IsVoteKickStarted=false;
  134. TextDrawHideForAll(Pozadina);
  135. TextDrawHideForAll(VoteKickTitle);
  136. TextDrawHideForAll(VoteKickName);
  137. TextDrawHideForAll(VoteKickVote);
  138. TextDrawSetString(VoteKickVote,"~g~~h~Da~w~: 0 ~r~Ne~w~: 0");
  139. TextDrawHideForAll(VoteKickTime);
  140. }
  141. return 1;
  142. }
  143. return 1;
  144. }
  145. //==============================================================ONDIALOGRESPONSE
  146. public OnDialogResponse(playerid,dialogid,response,listitem,inputtext[])
  147. {
  148. if(dialogid==DIALOG_VOTEKICK && response)
  149. {
  150. new string1[128];
  151. format(string, sizeof(string), ""GREEN"Upisi razlog zbog kojeg\nzelis izbaciti tog igraca.");
  152. if(IsVoteKickStarted == true) return SendClientMessage(playerid, COLOR_ERROR,"[Greska:] {BBBBBB}Jedno glasanje je upravo u toku, pricekaj da zavrsi pa zapocni novo glasanje.");
  153. if(IsNumeric(inputtext))
  154. {
  155. format(string1, sizeof(string1), "%s", inputtext);
  156. nput2 = string1;
  157. ShowPlayerDialog(playerid, rdialog, DIALOG_STYLE_INPUT, ""RED"Razlog:", string, "Start", "Cancel");
  158. }
  159. else
  160. {
  161. for(new i = 0; i<MAX_PLAYERS; i++)
  162. {
  163. GetPlayerName(playerid, name, sizeof(name));
  164. if(!strcmp(inputtext, name, true))
  165. {
  166. ShowPlayerDialog(playerid, rdialog, DIALOG_STYLE_INPUT, ""RED"Razlog:", string, "Start", "Cancel");
  167. break;
  168. }
  169. }
  170. }
  171. return 1;
  172. }
  173. if(dialogid==rdialog)
  174. {
  175. if(IsVoteKickStarted == true) return SendClientMessage(playerid, COLOR_ERROR,"[Greska:] {BBBBBB}Jedno glasanje je upravo u toku, pricekaj da zavrsi pa zapocni novo glasanje.");
  176. format(razlog, sizeof(razlog), ""RED"Razlog: "GREEN"%s", inputtext);
  177. StartVoteKick(strval(nput2));
  178. if(PlayerToKick == -1) return SendClientMessage(playerid, COLOR_ERROR, "[Greska]: {BBBBBB}Igrac nije online.");
  179. GetPlayerName(playerid, name2, sizeof(name2));
  180. format(string, sizeof(string), ""RED"%s"GREY" je zapoceo glasanje za izbacivanje igraca "RED"%s"GREY".", name2, name);
  181. SendClientMessageToAll(COLOR_OK, string);
  182. SendClientMessageToAll(COLOR_OK, razlog);
  183. SendClientMessageToAll(COLOR_OK, ""GREY"Upisi "GREEN"Da"GREY" ili "none"Ne"GREY" za glasanje.");
  184. return 1;
  185. }
  186. return 1;
  187. }
  188. //=================================================================STARTVOTEKICK
  189. stock StartVoteKick(playerid)
  190. {
  191. if(!IsPlayerConnected(playerid)) return 0;
  192. PlayerToKick = playerid;
  193. IsVoteKickStarted = true;
  194. TextDrawShowForAll(Pozadina);
  195. TextDrawShowForAll(VoteKickTitle);
  196. TextDrawShowForAll(VoteKickName);
  197. GetPlayerName(playerid,name,sizeof(name));
  198. TextDrawSetString(VoteKickName,name);
  199. TextDrawShowForAll(VoteKickVote);
  200. TextDrawShowForAll(VoteKickTime);
  201. for(new i = 0; i<MAX_PLAYERS; i++)
  202. HasPlayerVoted[i] = false;
  203. SetTimer("KickTimer",1000,false);
  204. return 1;
  205. }
  206. //======================================================================KICKTIME
  207. forward KickTimer();
  208. public KickTimer()
  209. {
  210. if(PlayerToKick == -1) return 1;
  211. if(seconds == 0) return EndVoteKick();
  212. seconds--;
  213. format(string,sizeof(string),"%02d",seconds);
  214. TextDrawHideForAll(VoteKickTime);
  215. TextDrawSetString(VoteKickTime, string);
  216. TextDrawShowForAll(VoteKickTime);
  217. SetTimer("KickTimer",1000,false);
  218. return 1;
  219. }
  220. //===================================================================ENDVOTEKICK
  221. stock EndVoteKick()
  222. {
  223. GetPlayerName(PlayerToKick, name, sizeof(name));
  224. if(Yes>No)
  225. {
  226. format(string, sizeof(string), "{C14124}%s {BBBBBB}je izbacen iz igre. [%d za DA | %d za NE]", name, Yes, No);
  227. SendClientMessageToAll(COLOR_OK, string);
  228. SendClientMessageToAll(COLOR_OK, razlog);
  229. Kick(PlayerToKick);
  230. }
  231. else
  232. {
  233. format(string, sizeof(string), "{C14124}%s {BBBBBB}nije izbacen iz igre. [%d za DA | %d za NE]", name, Yes, No);
  234. SendClientMessageToAll(COLOR_OK, string);
  235. }
  236. SendClientMessageToAll(COLOR_OK, string);
  237. Yes=0,No=0,PlayerToKick=-1, seconds=60, IsVoteKickStarted=false;
  238. TextDrawHideForAll(Pozadina);
  239. TextDrawHideForAll(VoteKickTitle);
  240. TextDrawHideForAll(VoteKickName);
  241. TextDrawHideForAll(VoteKickVote);
  242. TextDrawSetString(VoteKickVote,"~g~~h~Da~w~: 0 ~r~Ne~w~: 0");
  243. TextDrawHideForAll(VoteKickTime);
  244. return 1;
  245. }
  246. //=====================================================================ISNUMERIC
  247. stock IsNumeric(str[])
  248. {
  249. for(new i=0; i<strlen(str); i++)
  250. {
  251. if(str[i]<'0' || str[i]>'9')
  252. return 0;
  253. }
  254. return 1;
  255. }
  256. //==================================================================ONPLAYERTEXT
  257. public OnPlayerText(playerid, text[])
  258. {
  259. if(!strcmp("Da", text, true) && strlen(text)==strlen("Da") && IsVoteKickStarted == true && HasPlayerVoted[playerid] == false)
  260. {
  261. Yes++;
  262. HasPlayerVoted[playerid]= true;
  263. SendClientMessage(playerid, COLOR_OK, "[Glasanje]: {BBBBBB}Hvala vam na glasu!, glasali ste za Da! | +1");
  264. format(string,sizeof(string), "~g~~h~Da~w~: %d ~r~Ne~w~: %d", Yes, No);
  265. TextDrawHideForAll(VoteKickVote);
  266. TextDrawSetString(VoteKickVote,string);
  267. TextDrawShowForAll(VoteKickVote);
  268. return 0;
  269. }
  270. if(!strcmp("Ne", text, true) && strlen(text)==strlen("Ne") && IsVoteKickStarted == true && HasPlayerVoted[playerid] == false)
  271. {
  272. No++;
  273. HasPlayerVoted[playerid]= true;
  274. SendClientMessage(playerid, COLOR_OK, "[Glasanje]: {BBBBBB}Hvala na glasu, glasali ste za Ne! | +1");
  275. format(string,sizeof(string), "~g~~h~Da~w~: %d ~r~Ne~w~: %d", Yes, No);
  276. TextDrawHideForAll(VoteKickVote);
  277. TextDrawSetString(VoteKickVote,string);
  278. TextDrawShowForAll(VoteKickVote);
  279. return 0;
  280. }
  281. return 1;
  282. }
Advertisement
Add Comment
Please, Sign In to add comment