spleef.txt 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. rankingtable = "spleefranks";
  2. game_short = "spleef";
  3. spleefed = map.new();
  4. resetblocks_loc = list.new();
  5. resetblocks_type = list.new();
  6. gamename = "§9Spleef";
  7. gosub("setstart");
  8. goto("simplelobby");
  9. @finalstart
  10. player_list = minigame.getPlayers(script_id);
  11. all_size = list.getSize(player_list);
  12. for(i = 0; i < all_size; i++) {
  13. msg.prefix(p, gamename, "The game has started.");
  14. p_uuid = list.getIndex(player_list, i);
  15. p = player.get(p_uuid);
  16. display.add(p, 0, gamename);
  17. display.add(p, 1, "Remaining players:");
  18. display.add(p, 2, text.number(all_size));
  19. entity.teleport(p, list.getIndex(startlocs, i));
  20. player.setGamemode(p, "survival");
  21. player.setFly(player, false);
  22. map.add(spleefed, p_uuid, 0);
  23. }
  24. @checkgame
  25. wait();
  26. if(event == "living_pre_hurt") {
  27. if(!isPlayer(living_entity)) {
  28. goto("checkgame");
  29. }
  30. player = living_entity;
  31. }
  32. if(player.hasMinigameId(player, script_id)) {
  33. ignoreGoto(event);
  34. }
  35. goto("checkgame");
  36. @living_pre_hurt
  37. cancel = true;
  38. if(damage.getType(damage_source) == "outOfWorld") {
  39. minigame.speakAll(gamename, concat("§6", player.getName(player), " §rfell down."));
  40. goto("loosegame");
  41. }
  42. goto("checkgame");
  43. @block_place
  44. @block_break
  45. cancel = true;
  46. goto("checkgame");
  47. @block_click
  48. if(action == "left") {
  49. if(list.contains(spleef_list, block_type)) {
  50. block.set(block_loc, "minecraft:air");
  51. list.add(resetblocks_loc, block_loc);
  52. list.add(resetblocks_type, block_type);
  53. p_uuid = player.getUuid(player);
  54. map.add(spleefed, p_uuid, map.get(spleefed, p_uuid) + 1);
  55. }
  56. }
  57. goto("checkgame");
  58. @player_giveup
  59. @player_logout
  60. minigame.speakAll(gamename, concat("§6", player.getName(player), " §rhas left the game."));
  61. @loosegame
  62. script = script.getFromId(script_id);
  63. minigame.kickplayer(script, player);
  64. size = list.getSize(player_list);
  65. minigame.displayAll(2, text.number(size));
  66. showstats(player, false);
  67. if(size < minplayers) {
  68. winner_uuid = list.getIndex(player_list, 0);
  69. winner = player.get(winner_uuid);
  70. goto("win");
  71. }
  72. goto("checkgame");
  73. @win
  74. minigame.speakAll(gamename, concat("§6", player.getName(winner), " §rhas won the game."));
  75. for(i = 0; i < list.getSize(resetblocks_loc); i++) {
  76. block.set(list.getIndex(resetblocks_loc, i), list.getIndex(resetblocks_type, i));
  77. }
  78. showstats(winner, true);
  79. minigame.kickPlayer(script, winner);
  80. minigame.term(script, gamesignloc);
  81. term();
  82. function showstats(player, won) { //Player player, Boolean won
  83. player_id = player.getId(player);
  84. last_record = ranking.getPoints($rankingtable, player_id);
  85. if(won) {
  86. last_record++;
  87. }
  88. played_games = minigame.getPlayed(player_id, $game_short) + 1;
  89. minigame.setPlayed(player_id, $game_short, played_games);
  90. ranking.setPoints($rankingtable, player_id, last_record);
  91. minigame.statsHeader(player, $gamename, "§e");
  92. minigame.statsLine(player, "§e", "Won games", text.number(last_record));
  93. minigame.statsLine(player, "§e", "Played games", text.number(played_games));
  94. if(played_games != 0) {
  95. minigame.statsLine(player, "§e", "Win ratio", concat(text.number(math.roundComma((last_record / played_games) * 100, 2)), "%"));
  96. }
  97. }