ranklist.txt 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. event.load("custom_command");
  2. stats_prefix = "§bStatistic";
  3. games = list.new();
  4. inverting_list = list.new();
  5. list.add(inverting_list, "5x5");
  6. list.add(inverting_list, "7x7");
  7. list.add(inverting_list, "10x10");
  8. list.add(inverting_list, "5x5cl");
  9. list.add(inverting_list, "7x7cl");
  10. list.add(inverting_list, "10x10cl");
  11. ranking.add("§b", "BedWars", "bw", "bwranks", "All Kills", "DESC", null);
  12. ranking.add("§c", "RageMode", "rm", "rmranks", "All Kills", "DESC", null);
  13. ranking.add("§5", "Rebuild", "rebuild", "rebuildranks", "All solved patterns", "DESC", null);
  14. ranking.add("§d", "FastBridge", "fb", "fastbridgeranks", "Points Record", "DESC", null);
  15. ranking.add("§6", "Snowfight", "snow", "snowranks", "Kills", "DESC", null);
  16. ranking.add("§c", "JR-Death", "tjr", "tjrranks", "Checkpoints | Time", "DESC", "ASC");
  17. ranking.add("§a", "JR-Ice", "ijr", "icejrranks", "Checkpoints | Time", "DESC", "ASC");
  18. ranking.add("§a", "JR-Rooms", "jr_rooms", "jr_room_ranks", "Checkpoints | Time", "DESC", "ASC");
  19. ranking.add("§a", "JR-Endless", "jr", "jumpranks", "Points Record", "DESC", null);
  20. ranking.add("§d", "Letters", "letter", "letterranks", "Time", "ASC", null);
  21. ranking.add("§a", "Sammelfieber", "sfsingle", "sfsingle", "Points Record", "DESC", null);
  22. ranking.add("§2", "Buttons", "button", "buttonranks", "Points Record", "DESC", null);
  23. ranking.add("§9", "HideAndSeek", "hs", "fncranks", "Wins", "DESC", null);
  24. ranking.add("§9", "Inverting", "inv", "invertranks", "Points Record", "ASC", null);
  25. ranking.add("§9", "Spleef", "spleef", "spleefranks", "Wins", "DESC", null);
  26. ranking.add("§c", "Knockfight", "knock", "knockranks", "All Kills", "DESC", null);
  27. ranking.add("§9", "Leapfrog", "lf", "leapfrogranks", "Points Record", "DESC", null);
  28. ranking.add("§6", "Parcour", null, "parcourranks1", "Time", "ASC", null);
  29. ranking.add("§e", "Halma", "halma", "halmaranks", "Wins", "DESC", null);
  30. ranking.add("§e", "ShoppingChaos", "sc", "shoppingranks", "Max Items", "DESC", null);
  31. ranking.add("§e", "MengerRun", "mr", "mrranks", "Wins", "DESC", null);
  32. ranking.add("§c", "AmongUs", "among_us", "among_us_ranks", "Time", "ASC", null);
  33. ranking.register("invertranks5x5");
  34. ranking.register("invertranks7x7");
  35. ranking.register("invertranks10x10");
  36. ranking.register("invertranks5x5cl");
  37. ranking.register("invertranks7x7cl");
  38. ranking.register("invertranks10x10cl");
  39. msg("dev", "§bStatistics §rloaded");
  40. @wait
  41. wait();
  42. if(event == "custom_command") {
  43. command = text.toLowerCase(command);
  44. size = list.getSize(args);
  45. if(command == "stats") {
  46. if(size == 0) {
  47. @statshelp
  48. msg.prefix(player, stats_prefix, "§r/stats ...");
  49. msg(player, "§b - <game> §rShows own stats");
  50. msg(player, "§b - <game> top §rShows Top Ten");
  51. msg(player, "§b - <game> <position> §rShows stats from a position");
  52. msg(player, "§b - <game> <player> §rShows stats from a player");
  53. if(perm.has(player, "stats.remove")) {
  54. msg(player, "§b - <game> <player> remove §rRemoves stats from a player");
  55. }
  56. goto("wait");
  57. }
  58. gamename = list.getIndex(args, 0);
  59. if(game.getArray(gamename) == null) {
  60. msg.prefix(player, stats_prefix, "Unknown game.");
  61. goto("wait");
  62. }
  63. table = game.getRankingTable(gamename);
  64. if(size == 1) {
  65. p_name = player.getName(player);
  66. playerStatsCore(player, gamename, p_name);
  67. goto("wait");
  68. }
  69. if(size == 2) {
  70. arg1 = list.getIndex(args, 1);
  71. if(isDouble(arg1)) {
  72. order = game.getOrder(gamename);
  73. order2 = game.getOrder2(gamename);
  74. a = ranking.getArrayFromRank(table, arg1, order, order2);
  75. if(a == null) {
  76. msg.prefix(player, stats_prefix, "Invalid rank.");
  77. goto("wait");
  78. }
  79. p_name = player.getNameFromId(a[0]);
  80. playerStatsCore(player, gamename, p_name);
  81. goto("wait");
  82. }
  83. arg1 = text.toLowerCase(arg1);
  84. if(arg1 == "top") {
  85. color = game.getColor(gamename);
  86. if(gamename == "Inverting") {
  87. msg.prefix(player, concat(color, gamename), "Click for Top Ten");
  88. printClick(player, "Inverting 5x5", "/topinvstats 5x5");
  89. printClick(player, "Inverting 7x7", "/topinvstats 7x7");
  90. printClick(player, "Inverting 10x10", "/topinvstats 10x10");
  91. printClick(player, "Inverting Classic 5x5", "/topinvstats 5x5cl");
  92. printClick(player, "Inverting Classic 7x7", "/topinvstats 7x7cl");
  93. printClick(player, "Inverting Classic 10x10", "/topinvstats 10x10cl");
  94. goto("wait");
  95. }
  96. showTopStats(player, gamename, table);
  97. goto("wait");
  98. }
  99. }
  100. arg1 = list.getIndex(args, 1);
  101. if(!checkIfEverOnline(arg1)) {
  102. msg.prefix(player, stats_prefix, "This player has never been online.");
  103. goto("wait");
  104. }
  105. p_name = player.getName(player.getUuid(arg1));
  106. if(size == 2) {
  107. playerStatsCore(player, gamename, p_name);
  108. goto("wait");
  109. }
  110. if(size == 3) {
  111. arg2 = text.toLowerCase(list.getIndex(args, 2));
  112. if(arg2 == "remove") {
  113. if(table == "invertranks") {
  114. color = game.getColor(gamename);
  115. msg.prefix(player, concat(color, gamename), concat("Click to remove stats from ", p_name));
  116. printClick(player, "Inverting 5x5", concat("/removeinvstats ", p_name, " 5x5"));
  117. printClick(player, "Inverting 7x7", concat("/removeinvstats ", p_name, " 7x7"));
  118. printClick(player, "Inverting 10x10", concat("/removeinvstats ", p_name, " 10x10"));
  119. printClick(player, "Inverting Classic 5x5", concat("/removeinvstats ", p_name, " 5x5cl"));
  120. printClick(player, "Inverting Classic 7x7", concat("/removeinvstats ", p_name, " 7x7cl"));
  121. printClick(player, "Inverting Classic 10x10", concat("/removeinvstats ", p_name, " 10x10cl"));
  122. goto("wait");
  123. }
  124. p_uuid = player.getUuid(p_name);
  125. if(p_uuid == null) {
  126. p_uuid = player.getUuid(arg1);
  127. }
  128. p_id = player.getId(p_uuid);
  129. game_short = game.getShort(gamename);
  130. ranking.removePlayer(p_id, table, game_short);
  131. msg.prefix(player, stats_prefix, concat("§e", p_name, "§r from statistic removed."));
  132. goto("wait");
  133. }
  134. }
  135. goto("statshelp");
  136. }
  137. if(command == "invstats") {
  138. if(size != 2) {
  139. goto("wait");
  140. }
  141. p_name = list.getIndex(args, 0);
  142. if(!checkIfEverOnline(p_name)) {
  143. goto("wait");
  144. }
  145. sub_game = list.getIndex(args, 1);
  146. if(!list.contains(inverting_list, sub_game)) {
  147. goto("wait");
  148. }
  149. gamename = "Inverting";
  150. table = game.getRankingTable(gamename);
  151. table = concat(table, sub_game);
  152. message = game.getMessage(gamename);
  153. color = game.getColor(gamename);
  154. msg.prefix(player, concat(color, gamename), concat("§eWertung nach: §r", message));
  155. showPlayerStats(player, gamename, table, p_name);
  156. goto("wait");
  157. }
  158. if(command == "topinvstats") {
  159. if(size != 1) {
  160. goto("wait");
  161. }
  162. sub_game = list.getIndex(args, 0);
  163. if(!list.contains(inverting_list, sub_game)) {
  164. goto("wait");
  165. }
  166. gamename = "Inverting";
  167. table = game.getRankingTable(gamename);
  168. table = concat(table, sub_game);
  169. showTopStats(player, gamename, table);
  170. goto("wait");
  171. }
  172. if(command == "removeinvstats") {
  173. if(size != 2) {
  174. goto("wait");
  175. }
  176. p_name = list.getIndex(args, 0);
  177. if(!checkIfEverOnline(p_name)) {
  178. goto("wait");
  179. }
  180. sub_game = list.getIndex(args, 1);
  181. if(!list.contains(inverting_list, sub_game)) {
  182. goto("wait");
  183. }
  184. gamename = "Inverting";
  185. p_uuid = player.getUuid(p_name);
  186. p_id = player.getId(p_uuid);
  187. p_name = player.getNameFromId(p_id);
  188. table = game.getRankingTable(gamename);
  189. table = concat(table, sub_game);
  190. game_short = concat(game.getShort(gamename), sub_game);
  191. ranking.removePlayer(p_id, table, game_short);
  192. msg.prefix(player, stats_prefix, concat("§e", p_name, "§r from statistic removed."));
  193. goto("wait");
  194. }
  195. }
  196. goto("wait");
  197. function printClick(player, show_text, command) {
  198. msg(player, text.click(show_text, command));
  199. }
  200. function playerStatsCore(player, gamename, p_name) {
  201. color = game.getColor(gamename);
  202. if(gamename == "Inverting") {
  203. msg.prefix(player, concat(color, gamename), concat("Click for stats from §b", p_name));
  204. printClick(player, "Inverting 5x5", concat("/invstats ", p_name, " 5x5"));
  205. printClick(player, "Inverting 7x7", concat("/invstats ", p_name, " 7x7"));
  206. printClick(player, "Inverting 10x10", concat("/invstats ", p_name, " 10x10"));
  207. printClick(player, "Inverting Classic 5x5", concat("/invstats ", p_name, " 5x5cl"));
  208. printClick(player, "Inverting Classic 7x7", concat("/invstats ", p_name, " 7x7cl"));
  209. printClick(player, "Inverting Classic 10x10", concat("/invstats ", p_name, " 10x10cl"));
  210. return;
  211. }
  212. table = game.getRankingTable(gamename);
  213. message = game.getMessage(gamename);
  214. msg.prefix(player, concat(color, gamename), concat("§eWertung nach: §r", message));
  215. showPlayerStats(player, gamename, table, p_name);
  216. }
  217. function showPlayerStats(player, gamename, table, p_name) {
  218. p_id = player.getId(player.getUuid(p_name));
  219. order = game.getOrder(gamename);
  220. order2 = game.getOrder2(gamename);
  221. rang = ranking.getPlayerRank(p_id, table, order, order2);
  222. if(rang == -1) {
  223. msg.prefix(player, $stats_prefix, "No data available.");
  224. } else {
  225. a = ranking.getPlayerStats(p_id, table, order, order2);
  226. points = a[1];
  227. if(gamename == "Letters" || gamename == "AmongUs") {
  228. sendTimedRank(player, p_name, rang, points);
  229. } elseif(gamename == "Parcour") {
  230. sendMsTimedRank(player, p_name, rang, points);
  231. } elseif(gamename == "JR-Death") {
  232. points--;
  233. sec_points = a[2];
  234. sendJrRank(player, p_name, rang, points, sec_points);
  235. } elseif(gamename == "JR-Rooms" || gamename == "JR-Ice") {
  236. sec_points = a[2];
  237. sendJrRank(player, p_name, rang, points, sec_points);
  238. } else {
  239. sendRank(player, p_name, rang, points);
  240. }
  241. }
  242. }
  243. function showTopStats(player, gamename, table) {
  244. message = game.getMessage(gamename);
  245. color = game.getColor(gamename);
  246. order = game.getOrder(gamename);
  247. order2 = game.getOrder2(gamename);
  248. list = ranking.getTopTenList(table, order, order2);
  249. if(list.getSize(list) == 0) {
  250. msg.prefix(player, concat(color, gamename), "Nobody played this game.");
  251. return;
  252. }
  253. msg(player, "");
  254. msg.prefix(player, concat(color, gamename), concat("§eWertung nach: §r", message));
  255. for(i = 0; i < 10; i++) {
  256. if(i == list.getSize(list)) {
  257. break;
  258. }
  259. a = list.getIndex(list, i);
  260. p_name = player.getNameFromId(a[0]);
  261. points = a[1];
  262. rang = i + 1;
  263. if(gamename == "Letters" || gamename == "AmongUs") {
  264. sendTimedRank(player, p_name, rang, points);
  265. } elseif(gamename == "Parcour") {
  266. sendMsTimedRank(player, p_name, rang, points);
  267. } elseif(gamename == "JR-Death") {
  268. points--;
  269. sec_points = a[2];
  270. sendJrRank(player, p_name, rang, points, sec_points);
  271. } elseif(gamename == "JR-Rooms" || gamename == "JR-Ice") {
  272. sec_points = a[2];
  273. sendJrRank(player, p_name, rang, points, sec_points);
  274. } else {
  275. sendRank(player, p_name, rang, points);
  276. }
  277. }
  278. msg(player, "");
  279. showPlayerStats(player, gamename, table, player.getName(player));
  280. }
  281. function ranking.add(colorcode, name, game_short, rankingtable, message, order, order2) {
  282. a = array.new(7);
  283. a[0] = colorcode;
  284. a[1] = name;
  285. a[2] = game_short;
  286. a[3] = rankingtable;
  287. a[4] = message;
  288. a[5] = order;
  289. a[6] = order2;
  290. list.add($games, a);
  291. if(rankingtable == "invertranks") {
  292. return;
  293. }
  294. ranking.register(rankingtable);
  295. }
  296. function game.getArray(gamename) {
  297. iter = list.iterator($games);
  298. while(hasNext(iter)) {
  299. a = next(iter);
  300. if(a[1] == gamename) {
  301. return a;
  302. }
  303. }
  304. return null;
  305. }
  306. function game.getColor(gamename) {
  307. a = game.getArray(gamename);
  308. return a[0];
  309. }
  310. function game.getShort(gamename) {
  311. a = game.getArray(gamename);
  312. return a[2];
  313. }
  314. function game.getRankingTable(gamename) {
  315. a = game.getArray(gamename);
  316. return a[3];
  317. }
  318. function game.getMessage(gamename) {
  319. a = game.getArray(gamename);
  320. return a[4];
  321. }
  322. function game.getOrder(gamename) {
  323. a = game.getArray(gamename);
  324. return a[5];
  325. }
  326. function game.getOrder2(gamename) {
  327. a = game.getArray(gamename);
  328. return a[6];
  329. }
  330. function sendRank(player, p_name, rang, points) {
  331. msg(player, concat("§6", text.number(rang), " §r", p_name, " §e", text.number(points)));
  332. }
  333. function sendJrRank(player, p_name, rang, points, sec_points) {
  334. msg(player, concat("§6", text.number(rang), " §r", p_name, " §e", text.number(points), " | ", time.getClockString(sec_points / 1000)));
  335. }
  336. function sendTimedRank(player, p_name, rang, points) {
  337. msg(player, concat("§6", text.number(rang), " §r", p_name, " §e", text.number(math.roundDown(points / 60)), " min ", text.number(math.round(points % 60)), " s"));
  338. }
  339. function sendMsTimedRank(player, p_name, rang, points) {
  340. min = text.number(math.roundDown(points / 1000 / 60));
  341. sec = math.round(points / 1000 % 60);
  342. ms = text.number(points % 1000);
  343. if(sec < 10) {
  344. msg(player, concat("§6", text.number(rang), " §r", p_name, " §e", min, ":0", text.number(sec), ".", ms, " min"));
  345. } else {
  346. msg(player, concat("§6", text.number(rang), " §r", p_name, " §e", min, ":", text.number(sec), ".", ms, " min"));
  347. }
  348. }