123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263 |
- @core_start
- maxplayers = 1;
- sign.started(gamesignloc);
- event.load("player_join");
- 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("block_break");
- event.load("block_place");
- event.load("function_key");
- @wait
- wait();
- if(event == "living_pre_hurt") {
- if(!isPlayer(living_entity)) {
- goto("wait");
- }
- player = living_entity;
- }
- if(player.hasMinigameId(player, script_id)) {
- gosub("event_specific");
- ignoreGoto(event);
- }
- goto("wait");
- @player_join
- amount_checkpoints = list.getSize(spawn_locs) - 1;
- single_uuid = player.getUuid(player);
- jr.setStarttime();
- all_modules = jr.getModule(player);
- if(all_modules < amount_checkpoints) {
- jumpstage = all_modules;
- run_time = jr.getTime(player);
- jr.setLoopTime(run_time);
- jr.setRunTime(player, run_time);
- } else {
- jumpstage = jr.getRunModule(player);
- jr.setLoopTime(jr.getRunTime(player));
- }
- checkpoints = list.new();
- for(i = 0; i < list.getSize(spawn_locs); i++) {
- loc = list.getIndex(spawn_locs, i);
- b_loc = loc.mod(loc, -0.5, 0, -0.5);
- loc.setYaw(b_loc, 0);
- loc.setPitch(b_loc, 0);
- list.add(checkpoints, b_loc);
-
- b_loc_2 = loc.mod(b_loc, 1, 1, 1);
- if(i <= jumpstage) {
- continue;
- }
- event.addMoveData(b_loc, b_loc_2, -1, -1, player);
- }
- player.blockCommands(player);
- entity.teleport(player, list.getIndex(spawn_locs, jumpstage));
- player.clearInventory(player);
- display.reset(player);
- display.add(player, 0, gamename);
- stacks.set(player, 0, "km:refresh_red");
- stacks.set(player, 1, "km:return_red");
- stacks.setActive(player, true);
- title.clear(player);
- title.setTime(player, 20, 20, 20);
- title.setSub(player, mapname);
- title.send(player, gamename);
- gosub("stage_specific");
- player.setGamemode(player, "adventure");
- player.setFly(player, false);
- sgoto(20, "loop");
- goto("wait");
- @player_toss
- living.setEquip(player, "hand", item);
- cancel = true;
- goto("wait");
- @function_key
- if(key == 1) {
- living.setHealth(player, 20);
- jr.teleportModule(player, jumpstage);
- entity.setBurning(player, 0);
- jr.setLoopTime(jr.getRunTime(player));
- jr.setStarttime();
- goto("wait");
- }
- if(key == 2) {
- for(i = 1; i < amount_checkpoints; i++) {
- location1 = list.getIndex(checkpoints, i);
- location2 = loc.mod(location1, 1, 1, 1);
- event.addMoveData(location1, location2, -1, -1, player);
- }
-
- living.setHealth(player, 20);
- jr.setStarttime();
- jr.setLoopTime(0);
- jr.setRunTime(player, 0);
- jumpstage = 0;
- jr.setRunModule(player, jumpstage);
- jr.teleportModule(player, jumpstage);
- entity.setBurning(player, 0);
- }
- goto("wait");
- @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_type = damage.getType(damage_source);
- if(damage_type == "fall") {
- cancel = true;
- goto("wait");
- }
- if(damage_type == "arrow") {
- cancel = true;
- goto("wait");
- }
- goto("wait");
- @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");
- money.addBoost(player, 10);
- msg.prefix(player, "§6Commands", concat("§r", text.number(index), ".Checkpoint erreicht"));
- jumpstage = index;
- gosub("stage_specific");
- }
- //Alltime first try or already done?
- all_modules = jr.getModule(player);
- if(all_modules == amount_checkpoints) {
- alltime_first_try = false;
- } else {
- alltime_first_try = true;
- }
- run_time = jr.addRunTime(player, time.getMillis() - starttime);
- jr.setRunModule(player, jumpstage);
- jr.setStarttime();
- all_time = jr.getTime(player);
- //if(alltime_first_try) {
- if(jumpstage > all_modules) {
- jr.setModuleAndTime(player, jumpstage, run_time);
- goto("wait");
- }
- if(jumpstage == all_modules) {
- if(all_time == 0 || run_time < all_time) {
- jr.setModuleAndTime(player, jumpstage, run_time);
- msg.prefix(player, gamename, "Neuer Rekord!!!");
- }
- }
- goto("wait");
- //}
- /*if(jumpstage == amount_checkpoints) {
- if(all_time == 0 || run_time < all_time) {
- jr.setModuleAndTime(player, jumpstage, run_time);
- msg.prefix(player, gamename, "Neuer Rekord!!!");
- }
- }*/
- goto("wait");
- @loop
- player = player.get(single_uuid);
- seconds++;
- if(seconds == 60) {
- minutes++;
- seconds = 0;
- }
- if(seconds < 10) {
- display.add(player, 5, concat("Zeit: §e", text.number(minutes), ":0", text.number(seconds)));
- } else {
- display.add(player, 5, concat("Zeit: §e", text.number(minutes), ":", text.number(seconds)));
- }
- player.setHunger(player, 20);
- player.setSaturation(player, 5);
- sgoto(20, "loop");
- goto("wait");
- @player_logout
- @player_giveup
- player.setGamemode(player, "survival");
- player.unblockCommands(player);
- all_time = jr.getTime(player);
- all_module = jr.getModule(player);
- minigame.statsHeader(player, gamename, "§e");
- minigame.statsLine(player, "§e", "Checkpoints", text.number(all_module));
- minigame.statsLine(player, "§e", "Time", time.getClockString(all_time / 1000));
- script = script.getFromId(script_id);
- minigame.kickPlayer(script, player);
- minigame.term(script, gamesignloc);
- term();
- function jr.teleportModule(player, jumpstage) {
- entity.teleport(player, list.getIndex($spawn_locs, jumpstage));
- }
- function jr.setLoopTime(time) {
- time /= 1000;
- $minutes = math.roundDown(time / 60);
- $seconds = math.round(time % 60);
- }
- function jr.setStarttime() {
- $starttime = time.getMillis();
- }
- //THIS RUN
- function jr.setRunModule(player_or_id, module) {
- config = playerdata.getGames(player_or_id);
- config.set(config, $module_tag_run, module);
- config.saveAsync(config);
- }
- function jr.getRunModule(player_or_id) {
- config = playerdata.getGames(player_or_id);
- return config.getDouble(config, $module_tag_run, 0);
- }
- function jr.addRunTime(player_or_id, time) {
- run_time = jr.getRunTime(player_or_id) + time;
- jr.setRunTime(player_or_id, run_time);
- return run_time;
- }
- function jr.setRunTime(player_or_id, time) {
- config = playerdata.getGames(player_or_id);
- config.set(config, $time_tag_run, time);
- config.saveAsync(config);
- }
- function jr.getRunTime(player_or_id) {
- config = playerdata.getGames(player_or_id);
- return config.getDouble(config, $time_tag_run, 0);
- }
- //ALLTIME
- function jr.setModuleAndTime(player_or_id, module, time) {
- ranking.setSecPoints($rankingtable, player_or_id, module, time);
- }
- function jr.getTime(player_or_id) {
- return ranking.getSecPoints($rankingtable, player_or_id);
- }
- function jr.getModule(player_or_id) {
- return ranking.getPoints($rankingtable, player_or_id);
- }
|