spleef.txt 3.2 KB

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