123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- gamename = "§6Parcour";
- maxplayers = 1;
- sign.started(gamesignloc);
- event.load("function_key");
- event.load("player_move");
- event.load("living_pre_hurt");
- event.load("player_post_respawn");
- event.load("player_toss");
- event.load("player_logout");
- event.load("player_giveup");
- event.load("player_join");
- event.load("entity_click");
- event.load("block_break");
- event.load("block_place");
- sign_tag = block.getTag("minecraft:signs");
- tp_time = time.getMillis();
- minutes = 0;
- seconds = 0;
- jumpstage = 0;
- @wait
- wait();
- if(event == "living_pre_hurt") {
- if(!isPlayer(living_entity)) {
- goto("wait");
- }
- player = living_entity;
- }
- if(player.hasMinigameId(player, script_id)) {
- ignoreGoto(event);
- }
- goto("wait");
- @player_join
- player_uuid = player.getUuid(player);
- for(i = 0; i < list.getSize(checkpoints); i++) {
- location1 = list.getIndex(checkpoints, i);
- location2 = loc.mod(location1, 1, 0.99, 1);
- event.addMoveData(location1, location2, -1, -1, player);
- }
- player.blockCommands(player);
- entity.teleport(player, list.getIndex(spawn_locs, jumpstage));
- player.clearInventory(player);
- record_time = ranking.getPoints(rankingtable, player.getId(player));
- overall_record = ranking.getPointsFromRank(rankingtable, 1, "ASC", null);
- player.setGamemode(player, "survival");
- player.setFly(player, false);
- display.reset(player);
- display.add(player, 1, gamename);
- 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));
- 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));
- display.add(player, 4, concat("Checkpoints: §e", text.number(jumpstage), "/", text.number(list.getSize(checkpoints) - 1)));
- display.add(player, 5, concat("§rTime: §e0:00"));
- stacks.clear(player);
- stacks.set(player, 0, "km:return_red");
- stacks.setActive(player, true);
- sgoto(2, "loop");
- starttime = time.getMillis();
- goto("wait");
- @player_toss
- living.setEquip(player, "hand", item);
- cancel = true;
- goto("wait");
- @entity_click
- @block_break
- @block_place
- cancel = true;
- goto("wait");
- @player_post_respawn
- entity.teleport(player, list.getIndex(spawn_locs, jumpstage));
- goto("wait");
- @living_pre_hurt
- damage_source_type = damage.getType(damage_source);
- cancel = true;
- if(damage_source_type == "hotFloor") {
- cancel = false;
- checkpoint.tp(player);
- }
- elseif(damage_source_type == "lava") {
- cancel = false;
- }
- elseif(damage_source_type == "outOfWorld") {
- checkpoint.tp(player);
- }
- elseif(damage_source_type == "fall") {
- if(jumpstage == 7) {
- checkpoint.tp(player);
- }
- }
- goto("wait");
- function checkpoint.tp(player) {
- now_time = time.getMillis();
- if(now_time - $tp_time < 1000) {
- return;
- }
- $tp_time = now_time;
- entity.teleport(player, list.getIndex($spawn_locs, $jumpstage));
- }
- @player_move
- player_loc = entity.getLocation(player);
- x = loc.getCoord(player_loc, "bx");
- y = loc.getCoord(player_loc, "by");
- z = loc.getCoord(player_loc, "bz");
- loc = loc.new(gamesworld, x, y, z);
- index = list.getIndexOf(checkpoints, loc);
- if(index > jumpstage) {
- player.action(player, "§aCheckpoint gesetzt");
- time_ms = (time.getMillis() - starttime); //millisecons
- minutes = math.roundDown(time_ms / 1000 / 60);
- seconds = math.round(time_ms / 1000 % 60);
- ms = time_ms % 1000;
- if(seconds < 10) {
- time_string = concat(text.number(minutes), ":0", text.number(seconds), ".", text.number(ms));
- } else {
- time_string = concat(text.number(minutes), ":", text.number(seconds), ".", text.number(ms));
- }
- msg.prefix(player, gamename, concat("§r", text.number(index), ".Checkpoint erreicht §e", time_string));
- jumpstage = index;
- display.add(player, 4, concat("Checkpoints: §e", text.number(jumpstage), "/", text.number(list.getSize(checkpoints) - 1)));
- if(jumpstage == list.getSize(checkpoints) - 1) {
- minigame.statsHeader(player, gamename, "§e");
- if(record_time == 0 || time_ms < record_time) {
- if(record_time != 0) {
- diff = record_time - time_ms;
- msg(player, " §e- §rBeat own record by §e", text.number(diff / 1000), "§e s");
- }
- record_time = time_ms;
- }
- ranking.setPoints(rankingtable, player.getId(player), record_time);
- rec_minutes = text.number(math.roundDown(record_time / 1000 / 60));
- rec_seconds = math.round(record_time / 1000 % 60);
- rec_ms = text.number(math.round(record_time % 1000));
- if(rec_seconds < 10) {
- rec_time_string = concat(rec_minutes, ":0", text.number(rec_seconds), ".", rec_ms);
- } else {
- rec_time_string = concat(rec_minutes, ":", text.number(rec_seconds), ".", rec_ms);
- }
- minigame.statsLine(player, "§e", "Time", concat(time_string, " min"));
- minigame.statsLine(player, "§e", "Record", concat(rec_time_string, " min"));
- money.addBoost(player, math.round(-0.25 * (time_ms / 1000) + 60));
- goto("player_logout");
- }
- }
- goto("wait");
- @loop
- player = player.get(player_uuid);
- seconds++;
- if(seconds == 60) {
- minutes++;
- seconds = 0;
- }
- if(seconds < 10) {
- display.add(player, 5, concat("Time: §e", text.number(minutes), ":0", text.number(seconds)));
- } else {
- display.add(player, 5, concat("Time: §e", text.number(minutes), ":", text.number(seconds)));
- }
- player.setHunger(player, 20);
- player.setSaturation(player, 5);
- sgoto(20, "loop");
- goto("wait");
- @function_key
- if(key == 1) {
- entity.teleport(player, list.getIndex(spawn_locs, 0));
- for(i = 0; i <= jumpstage; i++) {
- location1 = list.getIndex(checkpoints, i);
- location2 = loc.mod(location1, 1, 0.99, 1);
- event.addMoveData(location1, location2, -1, -1, player);
- }
- minutes = 0;
- seconds = 0;
- jumpstage = 0;
- living.setHealth(player, 20);
- entity.setBurning(player, 0);
- display.add(player, 4, concat("Checkpoints: §e", text.number(jumpstage), "/", text.number(list.getSize(checkpoints) - 1)));
- display.add(player, 5, concat("§rTime: §e0:00"));
- starttime = time.getMillis();
- }
- goto("wait");
- @player_logout
- @player_giveup
- player.unblockCommands(player);
- script = script.getFromId(script_id);
- minigame.kickPlayer(script, player);
- minigame.term(script, gamesignloc);
- term();
|