parcour.txt 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. gamename = "§6Parcour";
  2. maxplayers = 1;
  3. sign.started(gamesignloc);
  4. event.load("block_click");
  5. event.load("player_move");
  6. event.load("entity_damage");
  7. event.load("player_post_respawn");
  8. event.load("player_drop");
  9. event.load("player_quit");
  10. event.load("player_giveup");
  11. event.load("minigame_join");
  12. event.load("entity_click");
  13. event.load("block_break");
  14. event.load("block_place");
  15. custom_red_return = item.custom.get("RETURN_RED");
  16. sign_tag = block.getTag("minecraft:signs");
  17. tp_time = time.getMillis();
  18. minutes = 0;
  19. seconds = 0;
  20. jumpstage = 0;
  21. @wait
  22. wait();
  23. if(event == "entity_damage") {
  24. if(!isPlayer(entity)) {
  25. goto("wait");
  26. }
  27. player = entity;
  28. }
  29. if(player.hasMinigameId(player, script_id)) {
  30. ignoreGoto(event);
  31. }
  32. goto("wait");
  33. @minigame_join
  34. player_uuid = player.getUuid(player);
  35. for(i = 0; i < list.getSize(checkpoints); i++) {
  36. location1 = list.getIndex(checkpoints, i);
  37. location2 = loc.mod(location1, 1, 0.99, 1);
  38. event.addMoveData(location1, location2, -1, -1, player);
  39. }
  40. player.blockCommands(player);
  41. entity.teleport(player, list.getIndex(spawn_locs, jumpstage));
  42. player.clearInventory(player);
  43. player.giveItem(player, item.custom.create("RETURN_RED", 1, "§fReset to start", null));
  44. record_time = ranking.getPoints(rankingtable, player.getId(player));
  45. overall_record = ranking.getPointsFromRank(rankingtable, 1, "ASC", null);
  46. player.setGamemode(player, "SURVIVAL");
  47. player.setFly(player, false);
  48. sb.add(player, 99, gamename);
  49. sb.add(player, 98, string.concat("Server Record: §e", string.number(math.roundDown(overall_record / 1000 / 60)), ":", string.number(math.round(overall_record / 1000 % 60)), ".", string.number(overall_record % 1000)));
  50. sb.add(player, 97, string.concat("Your Record: §e", string.number(math.roundDown(record_time / 1000 / 60)), ":", string.number(math.round(record_time / 1000 % 60)), ".", string.number(record_time % 1000)));
  51. sb.add(player, 96, string.concat("Checkpoints: §e", string.number(jumpstage), "/", string.number(list.getSize(checkpoints) - 1)));
  52. sb.add(player, 95, string.concat("§rTime: §e0:00"));
  53. sb.add(player, 94, sb.getSpacer());
  54. sgoto(2, "loop");
  55. starttime = time.getMillis();
  56. goto("wait");
  57. @player_drop
  58. cancel = true;
  59. item = item.entity.get(item_entity);
  60. living.setHand(player, item);
  61. goto("wait");
  62. @entity_click
  63. @block_break
  64. @block_place
  65. cancel = true;
  66. goto("wait");
  67. @player_post_respawn
  68. entity.teleport(player, list.getIndex(spawn_locs, jumpstage));
  69. goto("wait");
  70. @entity_damage
  71. damage_source_type = damage.getType(damage_source);
  72. cancel = true;
  73. if(damage_source_type == "hotFloor") {
  74. cancel = false;
  75. checkpoint.tp(player);
  76. }
  77. elseif(damage_source_type == "lava") {
  78. cancel = false;
  79. }
  80. elseif(damage_source_type == "outOfWorld") {
  81. checkpoint.tp(player);
  82. }
  83. elseif(damage_source_type == "fall") {
  84. if(jumpstage == 7) {
  85. checkpoint.tp(player);
  86. }
  87. }
  88. goto("wait");
  89. function checkpoint.tp(player) {
  90. now_time = time.getMillis();
  91. if(now_time - $tp_time < 1000) {
  92. return;
  93. }
  94. $tp_time = now_time;
  95. entity.teleport(player, list.getIndex($spawn_locs, $jumpstage));
  96. }
  97. @player_move
  98. player_loc = entity.getLocation(player);
  99. x = loc.getBlockX(player_loc);
  100. y = loc.getBlockY(player_loc);
  101. z = loc.getBlockZ(player_loc);
  102. loc = loc.new(gamesworld, x, y, z);
  103. index = list.getIndexOf(checkpoints, loc);
  104. if(index > jumpstage) {
  105. player.action(player, text.new("§aCheckpoint set"));
  106. time_ms = (time.getMillis() - starttime); //millisecons
  107. minutes = math.roundDown(time_ms / 1000 / 60);
  108. seconds = math.round(time_ms / 1000 % 60);
  109. ms = time_ms % 1000;
  110. if(seconds < 10) {
  111. time_string = string.concat(string.number(minutes), ":0", string.number(seconds), ".", string.number(ms));
  112. } else {
  113. time_string = string.concat(string.number(minutes), ":", string.number(seconds), ".", string.number(ms));
  114. }
  115. msg.prefix(player, gamename, string.concat("§r", string.number(index), ".Checkpoint erreicht §e", time_string));
  116. jumpstage = index;
  117. sb.add(player, 96, string.concat("Checkpoints: §e", string.number(jumpstage), "/", string.number(list.getSize(checkpoints) - 1)));
  118. if(jumpstage == list.getSize(checkpoints) - 1) {
  119. minigame.statsHeader(player, gamename, "§e");
  120. if(record_time == 0 || time_ms < record_time) {
  121. if(record_time != 0) {
  122. diff = record_time - time_ms;
  123. msg.string(player, " §e- §rBeat own record by §e", string.number(diff / 1000), "§e s");
  124. }
  125. record_time = time_ms;
  126. }
  127. ranking.setPoints(rankingtable, player.getId(player), record_time);
  128. rec_minutes = string.number(math.roundDown(record_time / 1000 / 60));
  129. rec_seconds = math.round(record_time / 1000 % 60);
  130. rec_ms = string.number(math.round(record_time % 1000));
  131. if(rec_seconds < 10) {
  132. rec_time_string = string.concat(rec_minutes, ":0", string.number(rec_seconds), ".", rec_ms);
  133. } else {
  134. rec_time_string = string.concat(rec_minutes, ":", string.number(rec_seconds), ".", rec_ms);
  135. }
  136. minigame.statsLine(player, "§e", "Time", string.concat(time_string, " min"));
  137. minigame.statsLine(player, "§e", "Record", string.concat(rec_time_string, " min"));
  138. //money.addBoost(player, math.round(-0.25 * (time_ms / 1000) + 60));
  139. goto("player_quit");
  140. }
  141. }
  142. goto("wait");
  143. @loop
  144. player = player.get(player_uuid);
  145. seconds++;
  146. if(seconds == 60) {
  147. minutes++;
  148. seconds = 0;
  149. }
  150. if(seconds < 10) {
  151. sb.add(player, 95, string.concat("Time: §e", string.number(minutes), ":0", string.number(seconds)));
  152. } else {
  153. sb.add(player, 95, string.concat("Time: §e", string.number(minutes), ":", string.number(seconds)));
  154. }
  155. player.setHunger(player, 20);
  156. player.setSaturation(player, 5);
  157. sgoto(20, "loop");
  158. goto("wait");
  159. @block_click
  160. item = living.getHand(player);
  161. if(item.custom.isType(item, custom_red_return)) {
  162. entity.teleport(player, list.getIndex(spawn_locs, 0));
  163. for(i = 0; i <= jumpstage; i++) {
  164. location1 = list.getIndex(checkpoints, i);
  165. location2 = loc.mod(location1, 1, 0.99, 1);
  166. event.addMoveData(location1, location2, -1, -1, player);
  167. }
  168. minutes = 0;
  169. seconds = 0;
  170. jumpstage = 0;
  171. living.setHealth(player, 20);
  172. entity.setBurning(player, 0);
  173. sb.add(player, 96, string.concat("Checkpoints: §e", string.number(jumpstage), "/", string.number(list.getSize(checkpoints) - 1)));
  174. sb.add(player, 95, string.concat("§rTime: §e0:00"));
  175. starttime = time.getMillis();
  176. }
  177. goto("wait");
  178. @player_quit
  179. @player_giveup
  180. player.unblockCommands(player);
  181. script = script.getFromId(script_id);
  182. minigame.kickPlayer(script, player);
  183. minigame.term(script, gamesignloc);
  184. term();