123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298 |
- placedblocks = list.new();
- points = list.new();
- spawn_locs = map.new();
- rankingtable = "fastbridgeranks";
- game_short = "fb";
- gamename = "§dFastBridge";
- specific_lobby_handling = true;
- no_core_reset = true;
- start_sound = sound.get("minecraft:block.note_block.harp");
- gosub("setstart");
- goto("simplelobby");
- @specificLobbyHandling
- if(event == "player_join") {
- entity.cleareffects(player);
- living.setHealth(player, 20);
- player.setHunger(player, 20);
- player.setSaturation(player, 5);
- player.clearInventory(player);
- display.reset(player);
- display.add(player, 0, gamename);
- display.add(player, 1, "§7Map:");
- display.add(player, 2, "§3", mapname);
- }
- return;
- @finalstart
- player_list = minigame.getPlayers(script_id);
- minigame.displayResetAll();
- minigame.displayAll(0, gamename);
- if(seconds < 10) {
- minigame.displayAll(1, concat("Time: ", text.number(minutes), ":0", text.number(seconds)));
- } else {
- minigame.displayAll(1, concat("TIme: ", text.number(minutes), ":", text.number(seconds)));
- }
- for(i = 0; i < list.getSize(player_list); i++) {
- p = player.get(list.getIndex(player_list, i));
- p_uuid = player.getUuid(p);
- msg.prefix(p, gamename, "The game has started.");
- spawnloc = list.getIndex(spawns, i);
- map.add(spawn_locs, p, spawnloc);
- entity.teleport(p, spawnloc);
- sound.spawnForPlayer(p, start_sound, sound_category_ambient);
- array = array.new(2);
- array[0] = p_uuid;
- array[1] = 0;
- list.add(points, array);
-
- player.setGamemode(p, "survival");
- player.setFly(p, false);
-
- title.clear(p);
- title.setTime(p, 0, 20, 0);
- }
- countdown = 5;
- @title
- for(i = 0; i < list.getSize(player_list); i++) {
- p = player.get(list.getIndex(player_list, i));
- title.send(p, concat("§4", text.number(countdown)));
- }
- if(countdown == 0) {
- sgoto(20, "loadevents");
- } else {
- sgoto(20, "title");
- countdown--;
- }
- @checkstart
- wait();
- if(event == "block_click") {
- cancel = true;
- }
- if(event == "player_logout" || event == "player_giveup") {
- removeFromPoints(player.getUuid(player));
- script = script.getFromId(script_id);
- minigame.kickPlayer(script, player);
- minigame.speakAll(gamename, concat(player.getName(player), " §rhas left the game."));
- if(list.getSize(player_list) < minplayers) {
- p = player.get(list.getIndex(player_list, 0));
- wincore(p);
- }
- }
- goto("checkstart");
- @loadevents
- minigame.speakAll(gamename, "Build faster than the others in one line.");
- event.load("player_post_respawn");
- sgoto(20, "loop");
- @checkgame
- wait();
- if(event == "living_pre_hurt") {
- if(!isPlayer(living_entity)) {
- goto("checkgame");
- }
- player = living_entity;
- }
- if(player.hasMinigameId(player, script_id)) {
- ignoreGoto(event);
- }
- goto("checkgame");
- @block_break
- cancel = true;
- goto("checkgame");
- @player_post_respawn
- entity.teleport(player, map.get(spawn_locs, player));
- goto("checkgame");
- @living_pre_hurt
- damage_type = damage.getType(damage_source);
- if(damage_type == "player") {
- cancel = true;
- }
- goto("checkgame");
- @loop
- if(seconds == 0) {
- seconds = 59;
- minutes--;
- if(minutes == -1) {
- sortPoints();
- array = list.getIndex(points, 0);
- winner = player.get(array[0]);
- for(i = 0; i < list.getSize(player_list); i++) {
- p = player.get(list.getIndex(player_list, i));
- if(p == winner) {
- money.addBoost(p, 64);
- } else {
- money.addBoost(p, 16);
- }
- }
- wincore(winner);
- }
- } else {
- seconds--;
- }
- if(seconds < 10) {
- minigame.displayAll(1, concat("Time: ", text.number(minutes), ":0", text.number(seconds)));
- } else {
- minigame.displayAll(1, concat("Time: ", text.number(minutes), ":", text.number(seconds)));
- }
- for(i = 0; i < list.getSize(player_list); i++) {
- item.drop(list.getIndex(spawns, i), list.getIndex(colors, i));
- ycheck = list.getIndex(ycheck_list, i);
- p = player.get(list.getIndex(player_list, i));
- y = loc.getY(entity.getLocation(p));
- if(y < ycheck) {
- entity.teleport(p, map.get(spawn_locs, p));
- entity.addEffect(p, "slowness", 240, 2);
- player.clearInventory(p);
- }
- }
- sgoto(20, "loop");
- goto("checkgame");
- @block_place
- spawnloc = map.get(spawn_locs, player);
- starty = loc.getY(spawnloc, "y") - 1;
- y = loc.getY(block_loc);
- if(starty == y) {
- startx = loc.getX(spawnloc, "x");
- startz = loc.getZ(spawnloc, "z");
- x = loc.getX(block_loc);
- z = loc.getZ(block_loc);
- if(coord == "x" && startx != x) {
- goto("cancelPlacement");
- } elseif(coord == "z" && startz != z) {
- goto("cancelPlacement");
- } else {
- cancel = false;
- raiseNumber(player.getUuid(player));
- list.add(placedblocks, block_loc);
- goto("checkgame");
- }
- }
- @cancelPlacement
- cancel = true;
- inv.update(player);
- goto("checkgame");
- @player_logout
- @player_giveup
- script = script.getFromId(script_id);
- minigame.kickPlayer(script, player);
- minigame.speakAll(gamename, concat(player.getName(player), " §rhas left the game."));
- if(list.getSize(player_list) < minplayers) {
- p = player.get(list.getIndex(player_list, 0));
- wincore(p);
- }
- goto("checkgame");
- function wincore(winner) {
- winner_name = player.getName(winner);
- minigame.speakAll($gamename, concat("§b", winner_name, " §rhas won!"));
- //Spielern das Inventar leeren, damit sie keine Blöcke mehr setzen können
- for(i = 0; i < list.getSize($player_list); i++) {
- player_uuid = list.getIndex($player_list, i);
- player = player.get(player_uuid);
- player.clearInventory(player);
- }
- //Blöcke resetten, während Spieler noch da sind, weil Chunks somit noch geladen sind
- for(i = 0; i < list.getSize($placedblocks); i++) {
- block.set(list.getIndex($placedblocks, i), "minecraft:air");
- }
- //Erst jetzt Spieler kicken/resetten/rausteleportieren
- for(i = 0; i < list.getSize($player_list); i++) {
- player_uuid = list.getIndex($player_list, i);
- player = player.get(player_uuid);
- player_id = player.getId(player);
-
- last_record = ranking.getPoints($rankingtable, player_id);
- playedgames = minigame.getPlayed(player_id, $game_short) + 1;
- minigame.setPlayed(player_id, $game_short, playedgames);
- record = getNumber(player_uuid);
- if(record < last_record) {
- record = last_record;
- }
- ranking.setPoints($rankingtable, player_id, record);
-
- fbwon = minigame.getWon(player, "fb");
- if(player == winner) {
- fbwon++;
- minigame.setWon(player, "fb", fbwon);
- }
-
- minigame.statsHeader(player, $gamename, "§e");
- for(h = 0; h < list.getSize($points); h++) {
- array = list.getIndex($points, h);
- msg(player, " §e- §r", text.number(array[1]), " §e", player.getName(array[0]));
- }
- msg(player, "");
- minigame.statsLine(player, "§e", "Won games", text.number(fbwon));
- minigame.statsLine(player, "§e", "Played games", text.number(playedgames));
- if(playedgames != 0) {
- minigame.statsLine(player, "§e", "Win ratio", concat(text.number(math.roundComma((fbwon / playedgames) * 100, 2)), "%"));
- }
- }
- entity.removeAll("net.minecraft.entity.item.ItemEntity", $middleloc, $radius);
- script = script.getFromId($script_id);
- minigame.kickAllPlayers(script);
- minigame.term(script, $gamesignloc);
- }
- function removeFromPoints(player_uuid) {
- for(i = 0; i < list.getSize($points); i++) {
- array = list.getIndex($points, i);
- if(array[0] == player_uuid) {
- list.removeIndex($points, i);
- break;
- }
- }
- }
- function sortPoints() {
- size = list.getSize($points);
- swapped = true;
- while(swapped) {
- swapped = false;
- for(i = 0; i < size - 1; i++) {
- array = list.getIndex($points, i);
- array2 = list.getIndex($points, i + 1);
- zahl1 = array[1];
- zahl2 = array2[1];
- if(zahl1 < zahl2) {
- list.setIndex($points, i, array2);
- list.setIndex($points, i + 1, array);
- swapped = true;
- }
- }
- }
- }
- function raiseNumber(player_uuid) {
- for(i = 0; i < list.getSize($points); i++) {
- array = list.getIndex($points, i);
- if(array[0] == player_uuid) {
- array[1] = array[1] + 1;
- break;
- }
- }
- }
- function getNumber(player_uuid) {
- for(i = 0; i < list.getSize($points); i++) {
- array = list.getIndex($points, i);
- if(array[0] == player_uuid) {
- return array[1];
- }
- }
- }
|