Advertisement
Guest User

Top highscore

a guest
Jan 3rd, 2020
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.61 KB | None | 0 0
  1. stock checktop5(playerid)
  2. {
  3. new pkill = Data[playerid][kills];
  4. new plnejm[MAX_PLAYER_NAME];
  5. GetPlayerNameEx(playerid, plnejm, MAX_PLAYER_NAME);
  6. if(pkill > topKills[1][tfKills]) // his kills are higher than kills on nr. 1
  7. {
  8. if(!strcmp(plnejm, topKills[1][tfName])) // if he's nr. 1 just update kills
  9. {
  10. topKills[1][tfKills] = pkill;
  11. SaveTopFive(); // save changes
  12. UpdateTopFiveLabel();
  13. return 1; // stop further checks
  14. }
  15. if(!strcmp(plnejm, topKills[2][tfName])) // if he's nr. 2
  16. {
  17. // assign temp variables
  18. new temp1name[MAX_PLAYER_NAME], temp1kills;
  19. strmid(temp1name, topKills[1][tfName], 0, strlen(topKills[1][tfName]), 255);
  20. temp1kills = topKills[1][tfKills];
  21. // put his info in nr. 1
  22. strmid(topKills[1][tfName], plnejm, 0, strlen(plnejm), 255);
  23. topKills[1][tfKills] = pkill;
  24. // now swap their positions
  25. strmid(topKills[2][tfName], temp1name, 0, strlen(temp1name), 255);
  26. topKills[2][tfKills] = temp1kills;
  27. SaveTopFive(); // save changes
  28. UpdateTopFiveLabel();
  29. return 1; // stop further checks
  30. }
  31. if(!strcmp(plnejm, topKills[3][tfName])) // if he's nr. 3
  32. {
  33. //asign temp variables for nr. 1 and nr. 2 because he jumped from 3rd to 1st place
  34. new temp1name[MAX_PLAYER_NAME], temp1kills;
  35. strmid(temp1name, topKills[1][tfName], 0, strlen(topKills[1][tfName]), 255);
  36. temp1kills = topKills[1][tfKills];
  37. new temp2name[MAX_PLAYER_NAME], temp2kills;
  38. strmid(temp2name, topKills[2][tfName], 0, strlen(topKills[2][tfName]), 255);
  39. temp2kills = topKills[2][tfKills];
  40. // put players info in nr. 1
  41. strmid(topKills[1][tfName], plnejm, 0, strlen(plnejm), 255);
  42. topKills[1][tfKills] = pkill;
  43. // now swap their positions
  44. strmid(topKills[2][tfName], temp1name, 0, strlen(temp1name), 255); // put guy that was 1st to 2nd place
  45. topKills[2][tfKills] = temp1kills;
  46. strmid(topKills[3][tfName], temp2name, 0, strlen(temp2name), 255); // put guy that was 2nd to 3rd place
  47. topKills[3][tfKills] = temp2kills;
  48. SaveTopFive(); // save changes
  49. UpdateTopFiveLabel();
  50. return 1; // stop further checks
  51. }
  52. if(!strcmp(plnejm, topKills[4][tfName])) // if he's nr. 4
  53. {
  54. //asign temp variables for nr. 1 and nr. 2 and nr. 3 because he jumped from 4th to 1st place
  55. new temp1name[MAX_PLAYER_NAME], temp1kills;
  56. strmid(temp1name, topKills[1][tfName], 0, strlen(topKills[1][tfName]), 255);
  57. temp1kills = topKills[1][tfKills];
  58. new temp2name[MAX_PLAYER_NAME], temp2kills;
  59. strmid(temp2name, topKills[2][tfName], 0, strlen(topKills[2][tfName]), 255);
  60. temp2kills = topKills[2][tfKills];
  61. new temp3name[MAX_PLAYER_NAME], temp3kills;
  62. strmid(temp3name, topKills[3][tfName], 0, strlen(topKills[3][tfName]), 255);
  63. temp3kills = topKills[3][tfKills];
  64. // put players info in nr. 1
  65. strmid(topKills[1][tfName], plnejm, 0, strlen(plnejm), 255);
  66. topKills[1][tfKills] = pkill;
  67. // now swap their positions
  68. strmid(topKills[2][tfName], temp1name, 0, strlen(temp1name), 255); // put guy that was 1st to 2nd place
  69. topKills[2][tfKills] = temp1kills;
  70. strmid(topKills[3][tfName], temp2name, 0, strlen(temp2name), 255); // put guy that was 2nd to 3rd place
  71. topKills[3][tfKills] = temp2kills;
  72. strmid(topKills[4][tfName], temp3name, 0, strlen(temp3name), 255); // put guy that was 3rd to 4th place
  73. topKills[4][tfKills] = temp3kills;
  74. SaveTopFive(); // save changes
  75. UpdateTopFiveLabel();
  76. return 1; // stop further checks
  77. }
  78. if(!strcmp(plnejm, topKills[5][tfName])) // if he's nr. 5
  79. {
  80. //asign temp variables for nr. 1 and nr. 2 and nr. 3 and nr. 4 because he jumped from 5th to 1st place
  81. new temp1name[MAX_PLAYER_NAME], temp1kills;
  82. strmid(temp1name, topKills[1][tfName], 0, strlen(topKills[1][tfName]), 255);
  83. temp1kills = topKills[1][tfKills];
  84. new temp2name[MAX_PLAYER_NAME], temp2kills;
  85. strmid(temp2name, topKills[2][tfName], 0, strlen(topKills[2][tfName]), 255);
  86. temp2kills = topKills[2][tfKills];
  87. new temp3name[MAX_PLAYER_NAME], temp3kills;
  88. strmid(temp3name, topKills[3][tfName], 0, strlen(topKills[3][tfName]), 255);
  89. temp3kills = topKills[3][tfKills];
  90. new temp4name[MAX_PLAYER_NAME], temp4kills;
  91. strmid(temp4name, topKills[4][tfName], 0, strlen(topKills[4][tfName]), 255);
  92. temp4kills = topKills[4][tfKills];
  93. // put players info in nr. 1
  94. strmid(topKills[1][tfName], plnejm, 0, strlen(plnejm), 255);
  95. topKills[1][tfKills] = pkill;
  96. // now swap their positions
  97. strmid(topKills[2][tfName], temp1name, 0, strlen(temp1name), 255); // put guy that was 1st to 2nd place
  98. topKills[2][tfKills] = temp1kills;
  99. strmid(topKills[3][tfName], temp2name, 0, strlen(temp2name), 255); // put guy that was 2nd to 3rd place
  100. topKills[3][tfKills] = temp2kills;
  101. strmid(topKills[4][tfName], temp3name, 0, strlen(temp3name), 255); // put guy that was 3rd to 4th place
  102. topKills[4][tfKills] = temp3kills;
  103. strmid(topKills[5][tfName], temp4name, 0, strlen(temp4name), 255); // put guy that was 4th to 5th place
  104. topKills[5][tfKills] = temp4kills;
  105. SaveTopFive(); // save changes
  106. UpdateTopFiveLabel();
  107. return 1; // stop further checks
  108. }
  109. else // he wasn't on top 5 highscore list so place him 1st and move everyone else a spot below (ultimately guy that was 5th will fall of the list)
  110. {
  111. //asign temp variables for nr. 1 and nr. 2 and nr. 3 and nr. 4 because he jumped to 1st place out of nowhere (probably set kills)
  112. new temp1name[MAX_PLAYER_NAME], temp1kills;
  113. strmid(temp1name, topKills[1][tfName], 0, strlen(topKills[1][tfName]), 255);
  114. temp1kills = topKills[1][tfKills];
  115. new temp2name[MAX_PLAYER_NAME], temp2kills;
  116. strmid(temp2name, topKills[2][tfName], 0, strlen(topKills[2][tfName]), 255);
  117. temp2kills = topKills[2][tfKills];
  118. new temp3name[MAX_PLAYER_NAME], temp3kills;
  119. strmid(temp3name, topKills[3][tfName], 0, strlen(topKills[3][tfName]), 255);
  120. temp3kills = topKills[3][tfKills];
  121. new temp4name[MAX_PLAYER_NAME], temp4kills;
  122. strmid(temp4name, topKills[4][tfName], 0, strlen(topKills[4][tfName]), 255);
  123. temp4kills = topKills[4][tfKills];
  124. // put players info in nr. 1
  125. strmid(topKills[1][tfName], plnejm, 0, strlen(plnejm), 255);
  126. topKills[1][tfKills] = pkill;
  127. // now swap their positions
  128. strmid(topKills[2][tfName], temp1name, 0, strlen(temp1name), 255); // put guy that was 1st to 2nd place
  129. topKills[2][tfKills] = temp1kills;
  130. strmid(topKills[3][tfName], temp2name, 0, strlen(temp2name), 255); // put guy that was 2nd to 3rd place
  131. topKills[3][tfKills] = temp2kills;
  132. strmid(topKills[4][tfName], temp3name, 0, strlen(temp3name), 255); // put guy that was 3rd to 4th place
  133. topKills[4][tfKills] = temp3kills;
  134. strmid(topKills[5][tfName], temp4name, 0, strlen(temp4name), 255); // put guy that was 4th to 5th place
  135. topKills[5][tfKills] = temp4kills;
  136. SaveTopFive(); // save changes
  137. UpdateTopFiveLabel();
  138. return 1; // stop further checks
  139. }
  140. }
  141. // kills aren't higher than 1st place so check others
  142. else if(pkill > topKills[2][tfKills]) // his kills are higher than kills on nr. 2
  143. {
  144. if(!strcmp(plnejm, topKills[1][tfName])) return 1; // if he's nr. 1 dont proceed (shouldn't happen but hey)
  145. if(!strcmp(plnejm, topKills[2][tfName])) // if he's nr. 2 just update kills
  146. {
  147. topKills[2][tfKills] = pkill;
  148. SaveTopFive(); // save changes
  149. UpdateTopFiveLabel();
  150. return 1; // stop further checks
  151. }
  152. if(!strcmp(plnejm, topKills[3][tfName])) // if he's nr. 3
  153. {
  154. //asign temp variables for nr. 2
  155. new temp2name[MAX_PLAYER_NAME], temp2kills;
  156. strmid(temp2name, topKills[2][tfName], 0, strlen(topKills[2][tfName]), 255);
  157. temp2kills = topKills[2][tfKills];
  158. // put players info in nr. 2
  159. strmid(topKills[2][tfName], plnejm, 0, strlen(plnejm), 255);
  160. topKills[2][tfKills] = pkill;
  161. // now swap their positions
  162. strmid(topKills[3][tfName], temp2name, 0, strlen(temp2name), 255); // put guy that was 2nd to 3rd place
  163. topKills[3][tfKills] = temp2kills;
  164. SaveTopFive(); // save changes
  165. UpdateTopFiveLabel();
  166. return 1; // stop further checks
  167. }
  168. if(!strcmp(plnejm, topKills[4][tfName])) // if he's nr. 4
  169. {
  170. //asign temp variables for nr. 2 and nr. 3 because he jumped from 4th to 2nd place
  171. new temp2name[MAX_PLAYER_NAME], temp2kills;
  172. strmid(temp2name, topKills[2][tfName], 0, strlen(topKills[2][tfName]), 255);
  173. temp2kills = topKills[2][tfKills];
  174. new temp3name[MAX_PLAYER_NAME], temp3kills;
  175. strmid(temp3name, topKills[3][tfName], 0, strlen(topKills[3][tfName]), 255);
  176. temp3kills = topKills[3][tfKills];
  177. // put players info in nr. 2
  178. strmid(topKills[2][tfName], plnejm, 0, strlen(plnejm), 255);
  179. topKills[2][tfKills] = pkill;
  180. // now swap their positions
  181. strmid(topKills[3][tfName], temp2name, 0, strlen(temp2name), 255); // put guy that was 2nd to 3rd place
  182. topKills[3][tfKills] = temp2kills;
  183. strmid(topKills[4][tfName], temp3name, 0, strlen(temp3name), 255); // put guy that was 3rd to 4th place
  184. topKills[4][tfKills] = temp3kills;
  185. SaveTopFive(); // save changes
  186. UpdateTopFiveLabel();
  187. return 1; // stop further checks
  188. }
  189. if(!strcmp(plnejm, topKills[5][tfName])) // if he's nr. 5
  190. {
  191. //asign temp variables for nr. 2 and nr. 3 and nr. 4 because he jumped from 5th to 2nd place
  192. new temp2name[MAX_PLAYER_NAME], temp2kills;
  193. strmid(temp2name, topKills[2][tfName], 0, strlen(topKills[2][tfName]), 255);
  194. temp2kills = topKills[2][tfKills];
  195. new temp3name[MAX_PLAYER_NAME], temp3kills;
  196. strmid(temp3name, topKills[3][tfName], 0, strlen(topKills[3][tfName]), 255);
  197. temp3kills = topKills[3][tfKills];
  198. new temp4name[MAX_PLAYER_NAME], temp4kills;
  199. strmid(temp4name, topKills[4][tfName], 0, strlen(topKills[4][tfName]), 255);
  200. temp4kills = topKills[4][tfKills];
  201. // put players info in nr. 2
  202. strmid(topKills[2][tfName], plnejm, 0, strlen(plnejm), 255);
  203. topKills[2][tfKills] = pkill;
  204. // now swap their positions
  205. strmid(topKills[3][tfName], temp2name, 0, strlen(temp2name), 255); // put guy that was 2nd to 3rd place
  206. topKills[3][tfKills] = temp2kills;
  207. strmid(topKills[4][tfName], temp3name, 0, strlen(temp3name), 255); // put guy that was 3rd to 4th place
  208. topKills[4][tfKills] = temp3kills;
  209. strmid(topKills[5][tfName], temp4name, 0, strlen(temp4name), 255); // put guy that was 4th to 5th place
  210. topKills[5][tfKills] = temp4kills;
  211. SaveTopFive(); // save changes
  212. UpdateTopFiveLabel();
  213. return 1; // stop further checks
  214. }
  215. else // he wasn't on top 5 highscore list so place him 2nd and move everyone else a spot below (ultimately guy that was 5th will fall of the list)
  216. {
  217. //asign temp variables for nr. 2 and nr. 3 and nr. 4 because he jumped to 2nd place out of nowhere (probably set kills)
  218. new temp2name[MAX_PLAYER_NAME], temp2kills;
  219. strmid(temp2name, topKills[2][tfName], 0, strlen(topKills[2][tfName]), 255);
  220. temp2kills = topKills[2][tfKills];
  221. new temp3name[MAX_PLAYER_NAME], temp3kills;
  222. strmid(temp3name, topKills[3][tfName], 0, strlen(topKills[3][tfName]), 255);
  223. temp3kills = topKills[3][tfKills];
  224. new temp4name[MAX_PLAYER_NAME], temp4kills;
  225. strmid(temp4name, topKills[4][tfName], 0, strlen(topKills[4][tfName]), 255);
  226. temp4kills = topKills[4][tfKills];
  227. // put players info in nr. 2
  228. strmid(topKills[2][tfName], plnejm, 0, strlen(plnejm), 255);
  229. topKills[2][tfKills] = pkill;
  230. // now swap their positions
  231. strmid(topKills[3][tfName], temp2name, 0, strlen(temp2name), 255); // put guy that was 2nd to 3rd place
  232. topKills[3][tfKills] = temp2kills;
  233. strmid(topKills[4][tfName], temp3name, 0, strlen(temp3name), 255); // put guy that was 3rd to 4th place
  234. topKills[4][tfKills] = temp3kills;
  235. strmid(topKills[5][tfName], temp4name, 0, strlen(temp4name), 255); // put guy that was 4th to 5th place
  236. topKills[5][tfKills] = temp4kills;
  237. SaveTopFive(); // save changes
  238. UpdateTopFiveLabel();
  239. return 1; // stop further checks
  240. }
  241. }
  242. // kills aren't higher than 2nd place either so check others
  243. else if(pkill > topKills[3][tfKills]) // his kills are higher than kills on nr. 3
  244. {
  245. if(!strcmp(plnejm, topKills[1][tfName])) return 1; // if he's nr. 1 dont proceed (shouldn't happen but hey)
  246. if(!strcmp(plnejm, topKills[2][tfName])) return 1; // if he's nr. 2 dont proceed (shouldn't happen but hey)
  247. if(!strcmp(plnejm, topKills[3][tfName])) // if he's nr. 3 just update kills
  248. {
  249. topKills[3][tfKills] = pkill;
  250. SaveTopFive(); // save changes
  251. UpdateTopFiveLabel();
  252. return 1; // stop further checks
  253. }
  254. if(!strcmp(plnejm, topKills[4][tfName])) // if he's nr. 4
  255. {
  256. //asign temp variables for nr. 3 because he jumped from 4th to 3rd place
  257. new temp3name[MAX_PLAYER_NAME], temp3kills;
  258. strmid(temp3name, topKills[3][tfName], 0, strlen(topKills[3][tfName]), 255);
  259. temp3kills = topKills[3][tfKills];
  260. // put players info in nr. 3
  261. strmid(topKills[3][tfName], plnejm, 0, strlen(plnejm), 255);
  262. topKills[3][tfKills] = pkill;
  263. // now swap their positions
  264. strmid(topKills[4][tfName], temp3name, 0, strlen(temp3name), 255); // put guy that was 3rd to 4th place
  265. topKills[4][tfKills] = temp3kills;
  266. SaveTopFive(); // save changes
  267. UpdateTopFiveLabel();
  268. return 1; // stop further checks
  269. }
  270. if(!strcmp(plnejm, topKills[5][tfName])) // if he's nr. 5
  271. {
  272. //asign temp variables for nr. 3 and nr. 4 because he jumped from 5th to 3rd place
  273. new temp3name[MAX_PLAYER_NAME], temp3kills;
  274. strmid(temp3name, topKills[3][tfName], 0, strlen(topKills[3][tfName]), 255);
  275. temp3kills = topKills[3][tfKills];
  276. new temp4name[MAX_PLAYER_NAME], temp4kills;
  277. strmid(temp4name, topKills[4][tfName], 0, strlen(topKills[4][tfName]), 255);
  278. temp4kills = topKills[4][tfKills];
  279. // put players info in nr. 3
  280. strmid(topKills[3][tfName], plnejm, 0, strlen(plnejm), 255);
  281. topKills[3][tfKills] = pkill;
  282. // now swap their positions
  283. strmid(topKills[4][tfName], temp3name, 0, strlen(temp3name), 255); // put guy that was 3rd to 4th place
  284. topKills[4][tfKills] = temp3kills;
  285. strmid(topKills[5][tfName], temp4name, 0, strlen(temp4name), 255); // put guy that was 4th to 5th place
  286. topKills[5][tfKills] = temp4kills;
  287. SaveTopFive(); // save changes
  288. UpdateTopFiveLabel();
  289. return 1; // stop further checks
  290. }
  291. else // he wasn't on top 5 highscore list so place him 3rd and move everyone else a spot below (ultimately guy that was 5th will fall of the list)
  292. {
  293. //asign temp variables for nr. 3 and nr. 4 because he jumped to 3rd place out of nowhere (probably set kills)
  294. new temp3name[MAX_PLAYER_NAME], temp3kills;
  295. strmid(temp3name, topKills[3][tfName], 0, strlen(topKills[3][tfName]), 255);
  296. temp3kills = topKills[3][tfKills];
  297. new temp4name[MAX_PLAYER_NAME], temp4kills;
  298. strmid(temp4name, topKills[4][tfName], 0, strlen(topKills[4][tfName]), 255);
  299. temp4kills = topKills[4][tfKills];
  300. // put players info in nr. 3
  301. strmid(topKills[3][tfName], plnejm, 0, strlen(plnejm), 255);
  302. topKills[3][tfKills] = pkill;
  303. // now swap their positions
  304. strmid(topKills[4][tfName], temp3name, 0, strlen(temp3name), 255); // put guy that was 3rd to 4th place
  305. topKills[4][tfKills] = temp3kills;
  306. strmid(topKills[5][tfName], temp4name, 0, strlen(temp4name), 255); // put guy that was 4th to 5th place
  307. topKills[5][tfKills] = temp4kills;
  308. SaveTopFive(); // save changes
  309. UpdateTopFiveLabel();
  310. return 1; // stop further checks
  311. }
  312. }
  313. // kills aren't higher than 3rd place either so check others
  314. else if(pkill > topKills[4][tfKills]) // his kills are higher than kills on nr. 4
  315. {
  316. if(!strcmp(plnejm, topKills[1][tfName])) return 1; // if he's nr. 1 dont proceed (shouldn't happen but hey)
  317. if(!strcmp(plnejm, topKills[2][tfName])) return 1; // if he's nr. 2 dont proceed (shouldn't happen but hey)
  318. if(!strcmp(plnejm, topKills[3][tfName])) return 1; // if he's nr. 3 dont proceed (shouldn't happen but hey)
  319. if(!strcmp(plnejm, topKills[4][tfName])) // if he's nr. 4 just update kills
  320. {
  321. topKills[4][tfKills] = pkill;
  322. SaveTopFive(); // save changes
  323. UpdateTopFiveLabel();
  324. return 1; // stop further checks
  325. }
  326. if(!strcmp(plnejm, topKills[5][tfName])) // if he's nr. 5
  327. {
  328. //asign temp variables for nr. 4 because he jumped from 5th to 4th place
  329. new temp4name[MAX_PLAYER_NAME], temp4kills;
  330. strmid(temp4name, topKills[4][tfName], 0, strlen(topKills[4][tfName]), 255);
  331. temp4kills = topKills[4][tfKills];
  332. // put players info in nr. 4
  333. strmid(topKills[4][tfName], plnejm, 0, strlen(plnejm), 255);
  334. topKills[4][tfKills] = pkill;
  335. // now swap their positions
  336. strmid(topKills[5][tfName], temp4name, 0, strlen(temp4name), 255); // put guy that was 4th to 5th place
  337. topKills[5][tfKills] = temp4kills;
  338. SaveTopFive(); // save changes
  339. UpdateTopFiveLabel();
  340. return 1; // stop further checks
  341. }
  342. else // he wasn't on top 5 highscore list so place him 4th and move everyone else a spot below (ultimately guy that was 5th will fall of the list)
  343. {
  344. //asign temp variables for nr. 4 because he jumped to 4th place out of nowhere (probably set kills)
  345. new temp4name[MAX_PLAYER_NAME], temp4kills;
  346. strmid(temp4name, topKills[4][tfName], 0, strlen(topKills[4][tfName]), 255);
  347. temp4kills = topKills[4][tfKills];
  348. // put players info in nr. 4
  349. strmid(topKills[4][tfName], plnejm, 0, strlen(plnejm), 255);
  350. topKills[4][tfKills] = pkill;
  351. // now swap their positions
  352. strmid(topKills[5][tfName], temp4name, 0, strlen(temp4name), 255); // put guy that was 4th to 5th place
  353. topKills[5][tfKills] = temp4kills;
  354. SaveTopFive(); // save changes
  355. UpdateTopFiveLabel();
  356. return 1; // stop further checks
  357. }
  358. }
  359. // kills aren't higher than 4th place either so check 5th
  360. else if(pkill > topKills[5][tfKills]) // his kills are higher than kills on nr. 5
  361. {
  362. if(!strcmp(plnejm, topKills[1][tfName])) return 1; // if he's nr. 1 dont proceed (shouldn't happen but hey)
  363. if(!strcmp(plnejm, topKills[2][tfName])) return 1; // if he's nr. 2 dont proceed (shouldn't happen but hey)
  364. if(!strcmp(plnejm, topKills[3][tfName])) return 1; // if he's nr. 3 dont proceed (shouldn't happen but hey)
  365. if(!strcmp(plnejm, topKills[4][tfName])) return 1; // if he's nr. 4 dont proceed (shouldn't happen but hey)
  366. if(!strcmp(plnejm, topKills[5][tfName])) // if he's nr. 5 just update kills
  367. {
  368. topKills[5][tfKills] = pkill;
  369. SaveTopFive(); // save changes
  370. UpdateTopFiveLabel();
  371. return 1; // stop further checks
  372. }
  373. else // he wasn't on top 5 highscore list so place him 5th and just delete guy that was 5th
  374. {
  375. // put players info in nr. 5
  376. strmid(topKills[5][tfName], plnejm, 0, strlen(plnejm), 255);
  377. topKills[5][tfKills] = pkill;
  378. SaveTopFive(); // save changes
  379. UpdateTopFiveLabel();
  380. return 1; // stop further checks
  381. }
  382. }
  383. return 1;
  384. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement