123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- rankingtable = "spleefranks";
- game_short = "spleef";
- spleefed = map.new();
- resetblocks_loc = list.new();
- resetblocks_type = list.new();
- gamename = "§9Spleef";
- gosub("setstart");
- goto("simplelobby");
- @finalstart
- player_list = minigame.getPlayers(script_id);
- all_size = list.getSize(player_list);
- for(i = 0; i < all_size; i++) {
- msg.prefix(p, gamename, "The game has started.");
- p_uuid = list.getIndex(player_list, i);
- p = player.get(p_uuid);
- display.add(p, 0, gamename);
- display.add(p, 1, "Remaining players:");
- display.add(p, 2, text.number(all_size));
- entity.teleport(p, list.getIndex(startlocs, i));
- player.setGamemode(p, "survival");
- player.setFly(player, false);
- map.add(spleefed, p_uuid, 0);
- }
- @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");
- @living_pre_hurt
- cancel = true;
- if(damage.getType(damage_source) == "outOfWorld") {
- minigame.speakAll(gamename, concat("§6", player.getName(player), " §rfell down."));
- goto("loosegame");
- }
- goto("checkgame");
- @block_place
- @block_break
- cancel = true;
- goto("checkgame");
- @block_click
- if(action == "left") {
- if(list.contains(spleef_list, block_type)) {
- block.set(block_loc, "minecraft:air");
- list.add(resetblocks_loc, block_loc);
- list.add(resetblocks_type, block_type);
- p_uuid = player.getUuid(player);
- map.add(spleefed, p_uuid, map.get(spleefed, p_uuid) + 1);
- }
- }
- goto("checkgame");
- @player_giveup
- @player_logout
- minigame.speakAll(gamename, concat("§6", player.getName(player), " §rhas left the game."));
- @loosegame
- script = script.getFromId(script_id);
- minigame.kickplayer(script, player);
- size = list.getSize(player_list);
- minigame.displayAll(2, text.number(size));
- showstats(player, false);
- if(size < minplayers) {
- winner_uuid = list.getIndex(player_list, 0);
- winner = player.get(winner_uuid);
- goto("win");
- }
- goto("checkgame");
- @win
- minigame.speakAll(gamename, concat("§6", player.getName(winner), " §rhas won the game."));
- for(i = 0; i < list.getSize(resetblocks_loc); i++) {
- block.set(list.getIndex(resetblocks_loc, i), list.getIndex(resetblocks_type, i));
- }
- showstats(winner, true);
- minigame.kickPlayer(script, winner);
- minigame.term(script, gamesignloc);
- term();
- function showstats(player, won) { //Player player, Boolean won
- player_id = player.getId(player);
- last_record = ranking.getPoints($rankingtable, player_id);
- if(won) {
- last_record++;
- }
-
- played_games = minigame.getPlayed(player_id, $game_short) + 1;
- minigame.setPlayed(player_id, $game_short, played_games);
- ranking.setPoints($rankingtable, player_id, last_record);
-
- minigame.statsHeader(player, $gamename, "§e");
- minigame.statsLine(player, "§e", "Won games", text.number(last_record));
- minigame.statsLine(player, "§e", "Played games", text.number(played_games));
- if(played_games != 0) {
- minigame.statsLine(player, "§e", "Win ratio", concat(text.number(math.roundComma((last_record / played_games) * 100, 2)), "%"));
- }
- }
|