parcour.txt 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. gamename = "§6Parcour";
  2. maxplayers = 1;
  3. sign.started(gamesignloc);
  4. event.load("function_key");
  5. event.load("player_move");
  6. event.load("living_pre_hurt");
  7. event.load("player_post_respawn");
  8. event.load("player_toss");
  9. event.load("player_logout");
  10. event.load("player_giveup");
  11. event.load("player_join");
  12. event.load("entity_click");
  13. event.load("block_break");
  14. event.load("block_place");
  15. sign_tag = block.getTag("minecraft:signs");
  16. tp_time = time.getMillis();
  17. minutes = 0;
  18. seconds = 0;
  19. jumpstage = 0;
  20. @wait
  21. wait();
  22. if(event == "living_pre_hurt") {
  23. if(!isPlayer(living_entity)) {
  24. goto("wait");
  25. }
  26. player = living_entity;
  27. }
  28. if(player.hasMinigameId(player, script_id)) {
  29. ignoreGoto(event);
  30. }
  31. goto("wait");
  32. @player_join
  33. player_uuid = player.getUuid(player);
  34. for(i = 0; i < list.getSize(checkpoints); i++) {
  35. location1 = list.getIndex(checkpoints, i);
  36. location2 = loc.mod(location1, 1, 0.99, 1);
  37. event.addMoveData(location1, location2, -1, -1, player);
  38. }
  39. player.blockCommands(player);
  40. entity.teleport(player, list.getIndex(spawn_locs, jumpstage));
  41. player.clearInventory(player);
  42. record_time = ranking.getPoints(rankingtable, player.getId(player));
  43. overall_record = ranking.getPointsFromRank(rankingtable, 1, "ASC", null);
  44. player.setGamemode(player, "survival");
  45. player.setFly(player, false);
  46. display.reset(player);
  47. display.add(player, 1, gamename);
  48. display.add(player, 2, "Server Record: §e", text.number(math.roundDown(overall_record / 1000 / 60)), ":", text.number(math.round(overall_record / 1000 % 60)), ".", text.number(overall_record % 1000));
  49. display.add(player, 3, "Your Record: §e", text.number(math.roundDown(record_time / 1000 / 60)), ":", text.number(math.round(record_time / 1000 % 60)), ".", text.number(record_time % 1000));
  50. display.add(player, 4, concat("Checkpoints: §e", text.number(jumpstage), "/", text.number(list.getSize(checkpoints) - 1)));
  51. display.add(player, 5, concat("§rTime: §e0:00"));
  52. stacks.clear(player);
  53. stacks.set(player, 0, "km:return_red");
  54. stacks.setActive(player, true);
  55. sgoto(2, "loop");
  56. starttime = time.getMillis();
  57. goto("wait");
  58. @player_toss
  59. living.setEquip(player, "hand", item);
  60. cancel = true;
  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. @living_pre_hurt
  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.getCoord(player_loc, "bx");
  100. y = loc.getCoord(player_loc, "by");
  101. z = loc.getCoord(player_loc, "bz");
  102. loc = loc.new(gamesworld, x, y, z);
  103. index = list.getIndexOf(checkpoints, loc);
  104. if(index > jumpstage) {
  105. player.action(player, "§aCheckpoint gesetzt");
  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 = concat(text.number(minutes), ":0", text.number(seconds), ".", text.number(ms));
  112. } else {
  113. time_string = concat(text.number(minutes), ":", text.number(seconds), ".", text.number(ms));
  114. }
  115. msg.prefix(player, gamename, concat("§r", text.number(index), ".Checkpoint erreicht §e", time_string));
  116. jumpstage = index;
  117. display.add(player, 4, concat("Checkpoints: §e", text.number(jumpstage), "/", text.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(player, " §e- §rBeat own record by §e", text.number(diff / 1000), "§e s");
  124. }
  125. record_time = time_ms;
  126. }
  127. ranking.setPoints(rankingtable, player.getId(player), record_time);
  128. rec_minutes = text.number(math.roundDown(record_time / 1000 / 60));
  129. rec_seconds = math.round(record_time / 1000 % 60);
  130. rec_ms = text.number(math.round(record_time % 1000));
  131. if(rec_seconds < 10) {
  132. rec_time_string = concat(rec_minutes, ":0", text.number(rec_seconds), ".", rec_ms);
  133. } else {
  134. rec_time_string = concat(rec_minutes, ":", text.number(rec_seconds), ".", rec_ms);
  135. }
  136. minigame.statsLine(player, "§e", "Time", concat(time_string, " min"));
  137. minigame.statsLine(player, "§e", "Record", concat(rec_time_string, " min"));
  138. money.addBoost(player, math.round(-0.25 * (time_ms / 1000) + 60));
  139. goto("player_logout");
  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. display.add(player, 5, concat("Time: §e", text.number(minutes), ":0", text.number(seconds)));
  152. } else {
  153. display.add(player, 5, concat("Time: §e", text.number(minutes), ":", text.number(seconds)));
  154. }
  155. player.setHunger(player, 20);
  156. player.setSaturation(player, 5);
  157. sgoto(20, "loop");
  158. goto("wait");
  159. @function_key
  160. if(key == 1) {
  161. entity.teleport(player, list.getIndex(spawn_locs, 0));
  162. for(i = 0; i <= jumpstage; i++) {
  163. location1 = list.getIndex(checkpoints, i);
  164. location2 = loc.mod(location1, 1, 0.99, 1);
  165. event.addMoveData(location1, location2, -1, -1, player);
  166. }
  167. minutes = 0;
  168. seconds = 0;
  169. jumpstage = 0;
  170. living.setHealth(player, 20);
  171. entity.setBurning(player, 0);
  172. display.add(player, 4, concat("Checkpoints: §e", text.number(jumpstage), "/", text.number(list.getSize(checkpoints) - 1)));
  173. display.add(player, 5, concat("§rTime: §e0:00"));
  174. starttime = time.getMillis();
  175. }
  176. goto("wait");
  177. @player_logout
  178. @player_giveup
  179. player.unblockCommands(player);
  180. script = script.getFromId(script_id);
  181. minigame.kickPlayer(script, player);
  182. minigame.term(script, gamesignloc);
  183. term();