rankingtable = "shoppingranks"; game_short = "sc"; specific_lobby_handling = true; no_core_reset = true; air = "minecraft:air"; air_item = read.item(air); emerald = read.item("minecraft:emerald"); emerald10 = read.item("minecraft:emerald", 10); gamename = "§eShoppingChaos"; start_sound = sound.get("minecraft:block.note_block.harp"); wall_signs_tag = block.getTag("minecraft:wall_signs"); facing_prop = block.getProperty("horizontal_facing"); players = map.new(); //Alle player_uuids mit Verweis auf die Team-Nr playersinteam = map.new(); //Anzahl der Spieler im Team teamidtolist = map.new(); //Team-Nr mit Verweis auf die Spielerlisten allteams = list.new(); //Alle Teams, die noch im Spiel sind items_list = list.new(); //Array-List: Alle Items mit Rezepten points = map.new(); //Punktestand der Teams sales_map = map.new(); //Key Entity. Value Item recipe_menus = map.new(); //Rezept-Menüs für jeden Spieler removed_perms = list.new(); //Spieler-Uuids, denen Building-Perms entfernt wurden waiters = list.new(); //Spieler in der Lobby ohne Teamzugehörigkeit colorcodes = map.new(); map.add(colorcodes, 0, "§9"); map.add(colorcodes, 1, "§c"); map.add(colorcodes, 2, "§e"); map.add(colorcodes, 3, "§2"); teamcolortext = map.new(); map.add(teamcolortext, 0, "§9blue"); map.add(teamcolortext, 1, "§cred"); map.add(teamcolortext, 2, "§eyellow"); map.add(teamcolortext, 3, "§2green"); iron_block = "minecraft:iron_block"; iron_ingot = "minecraft:iron_ingot"; gold_ingot = "minecraft:gold_ingot"; diamond = "minecraft:diamond"; ink_sac = "minecraft:ink_sac"; book = "minecraft:book"; stick = "minecraft:stick"; oak_planks = "minecraft:oak_planks"; quartz_block = "minecraft:quartz_block"; glass = "minecraft:glass"; apple = "minecraft:apple"; cobble = "minecraft:cobblestone"; redstone = "minecraft:redstone"; glowstone = "minecraft:glowstone"; gold_nugget = "minecraft:gold_nugget"; obsidian = "minecraft:obsidian"; ender_eye = "minecraft:ender_eye"; melon_slice = "minecraft:melon_slice"; carrot = "minecraft:carrot"; chest = "minecraft:chest"; coal = "minecraft:coal"; string = "minecraft:string"; furnace = "minecraft:furnace"; compass = "minecraft:compass"; blaze_powder = "minecraft:blaze_powder"; slime_ball = "minecraft:slime_ball"; blaze_rod = "minecraft:blaze_rod"; sugar_cane = "minecraft:sugar_cane"; sugar = "minecraft:sugar"; milk = "minecraft:milk_bucket"; egg = "minecraft:egg"; white_wool= "minecraft:white_wool"; wheat = "minecraft:wheat"; gunpowder = "minecraft:gunpowder"; sand = "minecraft:sand"; ender_pearl = "minecraft:ender_pearl"; leather = "minecraft:leather"; stone = "minecraft:stone"; smooth_stone = "minecraft:smooth_stone"; bow = "minecraft:bow"; flint = "minecraft:flint"; feather = "minecraft:feather"; pumpkin = "minecraft:pumpkin"; sugar = "minecraft:sugar"; egg = "minecraft:egg"; beef = "minecraft:beef"; porkchop = "minecraft:porkchop"; paper = "minecraft:paper"; brown_mushroom = "minecraft:brown_mushroom"; red_mushroom = "minecraft:red_mushroom"; bowl = "minecraft:bowl"; redstone_torch = "minecraft:redstone_torch"; quartz = "minecraft:quartz"; oak_slab = "minecraft:oak_slab"; cod = "minecraft:cod"; piston = "minecraft:piston"; tnt = "minecraft:tnt"; minecart = "minecraft:minecart"; stone_bricks = "minecraft:stone_bricks"; stone_pressure_plate = "minecraft:stone_pressure_plate"; addItem("minecraft:rail", iron_ingot, air, iron_ingot, iron_ingot, stick, iron_ingot, iron_ingot, air, iron_ingot); addItem("minecraft:oak_fence", air, air, air, oak_planks, stick, oak_planks, oak_planks, stick, oak_planks); addItem("minecraft:glass_bottle", glass, air, glass, air, glass, air, air, air, air); addItem("minecraft:dropper", cobble, cobble, cobble, cobble, air, cobble, cobble, redstone, cobble); addItem("minecraft:iron_sword", air, iron_ingot, air, air, iron_ingot, air, air, stick, air); addItem("minecraft:ladder", stick, air, stick, stick, stick, stick, stick, air, stick); addItem("minecraft:minecart", air, air, air, iron_ingot, air, iron_ingot, iron_ingot, iron_ingot, iron_ingot); addItem("minecraft:hopper", iron_ingot, air, iron_ingot, iron_ingot, chest, iron_ingot, air, iron_ingot, air); addItem("minecraft:redstone_torch", air, air, air, air, redstone, air, air, stick, air); addItem("minecraft:torch", air, air, air, air, coal, air, air, stick, air); addItem("minecraft:bow", air, stick, string, stick, air, string, air, stick, string); addItem("minecraft:cobblestone_wall", air, air, air, cobble, cobble, cobble, cobble, cobble, cobble); addItem("minecraft:stone", air, air, air, furnace, cobble, air, air, air, air); addItem("minecraft:oak_door", oak_planks, oak_planks, air, oak_planks, oak_planks, air, oak_planks, oak_planks, air); addItem("minecraft:oak_fence_gate", air, air, air, stick, oak_planks, stick, stick, oak_planks, stick); addItem("minecraft:stone_pressure_plate", air, air, air, stone, stone, air, air, air, air); addItem("minecraft:oak_pressure_plate", air, air, air, oak_planks, oak_planks, air, air, air, air); addItem("minecraft:oak_trapdoor", air, air, air, oak_planks, oak_planks, oak_planks, oak_planks, oak_planks, oak_planks); addItem("minecraft:bucket", iron_ingot, air, iron_ingot, air, iron_ingot, air, air, air, air); addItem("minecraft:iron_bars", iron_ingot, iron_ingot, iron_ingot, iron_ingot, iron_ingot, iron_ingot, air, air, air); addItem("minecraft:oak_sign", oak_planks, oak_planks, oak_planks, oak_planks, oak_planks, oak_planks, air, stick, air); addItem("minecraft:shears", air, iron_ingot, air, iron_ingot, air, air, air, air, air); addItem("minecraft:fishing_rod", air, air, stick, air, stick, string, stick, air, string); addItem("minecraft:compass", air, iron_ingot, air, iron_ingot, redstone, iron_ingot, air, iron_ingot, air); addItem("minecraft:oak_boat", oak_planks, air, oak_planks, oak_planks, oak_planks, oak_planks, air, air, air); addItem("minecraft:bowl", oak_planks, air, oak_planks, air, oak_planks, air, air, air, air); addItem("minecraft:white_wool", string, string, air, string, string, air, air, air, air); addItem("minecraft:wooden_sword", air, oak_planks, air, air, oak_planks, air, air, stick, air); addItem("minecraft:tripwire_hook", air, iron_ingot, air, air, stick, air, air, oak_planks, air); addItem("minecraft:chest_minecart", air, chest, air, air, minecart, air, air, air, air); addItem("minecraft:iron_door", iron_ingot, iron_ingot, air, iron_ingot, iron_ingot, air, iron_ingot, iron_ingot, air); addItem("minecraft:smooth_stone_slab", smooth_stone, smooth_stone, smooth_stone, air, air, air, air, air, air); addItem("minecraft:activator_rail", iron_ingot, stick, iron_ingot, iron_ingot, redstone_torch, iron_ingot, iron_ingot, stick, iron_ingot); addItem("minecraft:detector_rail", iron_ingot, air, iron_ingot, iron_ingot, stone_pressure_plate, iron_ingot, iron_ingot, redstone, iron_ingot); addItem("minecraft:dispenser", cobble, cobble, cobble, cobble, bow, cobble, cobble, redstone, cobble); addItem("minecraft:piston", oak_planks, oak_planks, oak_planks, cobble, iron_ingot, cobble, cobble, redstone, cobble); addItem("minecraft:repeater", redstone_torch, redstone, redstone_torch, stone, stone, stone, air, air, air); addItem("minecraft:comparator", air, redstone_torch, air, redstone_torch, quartz, redstone_torch, stone, stone, stone); addItem("minecraft:heavy_weighted_pressure_plate", air, air, air, iron_ingot, iron_ingot, air, air, air, air); addItem("minecraft:arrow", air, flint, air, air, stick, air, air, feather, air); addItem("minecraft:bookshelf", oak_planks, oak_planks, oak_planks, paper, paper, paper, oak_planks, oak_planks, oak_planks); addItem("minecraft:mushroom_stew", brown_mushroom, red_mushroom, bowl, air, air, air, air, air, air); addItem("minecraft:pumpkin_pie", pumpkin, sugar, egg, air, air, air, air, air, air); addItem("minecraft:cooked_beef", air, air, air, furnace, beef, air, air, air, air); addItem("minecraft:cooked_porkchop", air, air, air, furnace, porkchop, air, air, air, air); //Page2 addItem("minecraft:book", paper, paper, paper, leather, air, air, air, air, air); addItem("minecraft:map", paper, paper, paper, paper, compass, paper, paper, paper, paper); addItem("minecraft:ender_eye", ender_pearl, blaze_powder, air, air, air, air, air, air, air); addItem("minecraft:lead", air, string, string, air, slime_ball, string, string, air, air); addItem("minecraft:stone_brick_slab", stone_bricks, stone_bricks, stone_bricks, air, air, air, air, air, air); addItem("minecraft:brewing_stand", air, air, air, air, blaze_rod, air, cobble, cobble, cobble); addItem("minecraft:leather_helmet", leather, leather, leather, leather, air, leather, air, air, air); addItem("minecraft:leather_chestplate", leather, air, leather, leather, leather, leather, leather, leather, leather); addItem("minecraft:leather_leggings", leather, leather, leather, leather, air, leather, leather, air, leather); addItem("minecraft:leather_boots", air, air, air, leather, air, leather, leather, air, leather); addItem("minecraft:cauldron", iron_ingot, air, iron_ingot, iron_ingot, air, iron_ingot, iron_ingot, iron_ingot, iron_ingot); addItem("minecraft:clock", air, gold_ingot, air, gold_ingot, redstone, gold_ingot, air, gold_ingot, air); addItem("minecraft:paper", sugar_cane, sugar_cane, sugar_cane, air, air, air, air, air, air); addItem("minecraft:tnt", gunpowder, sand, gunpowder, sand, gunpowder, sand, gunpowder, sand, gunpowder); addItem("minecraft:magma_cream", air, air, air, slime_ball, blaze_powder, air, air, air, air); addItem("minecraft:bread", air, air, air, wheat, wheat, wheat, air, air, air); addItem("minecraft:white_bed", air, air, air, white_wool, white_wool, white_wool, oak_planks, oak_planks, oak_planks); addItem("minecraft:cake", milk, milk, milk, sugar, egg, sugar, wheat, wheat, wheat); addItem("minecraft:cooked_cod", air, air, air, furnace, cod, air, air, air, air); addItem("minecraft:tnt_minecart", air, air, air, air, tnt, air, air, minecart, air); addItem("minecraft:melon", melon_slice, melon_slice, melon_slice, melon_slice, melon_slice, melon_slice, melon_slice, melon_slice, melon_slice); addItem("minecraft:hay_block", wheat, wheat, wheat, wheat, wheat, wheat, wheat, wheat, wheat); addItem("minecraft:ender_chest", obsidian, obsidian, obsidian, obsidian, ender_eye, obsidian, obsidian, obsidian, obsidian); addItem("minecraft:sticky_piston", air, air, air, air, slime_ball, air, air, piston, air); addItem("minecraft:daylight_detector", glass, glass, glass, quartz, quartz, quartz, oak_slab, oak_slab, oak_slab); addItem("minecraft:golden_apple", gold_ingot, gold_ingot, gold_ingot, gold_ingot, apple, gold_ingot, gold_ingot, gold_ingot, gold_ingot); addItem("minecraft:jukebox", oak_planks, oak_planks, oak_planks, oak_planks, diamond, oak_planks, oak_planks, oak_planks, oak_planks); addItem("minecraft:anvil", iron_block, iron_block, iron_block, air, iron_ingot, air, iron_ingot, iron_ingot, iron_ingot); addItem("minecraft:quartz_stairs", quartz_block, air, air, quartz_block, quartz_block, air, quartz_block, quartz_block, quartz_block); addItem("minecraft:enchanting_table", air, book, air, diamond, obsidian, diamond, obsidian, obsidian, obsidian); addItem("minecraft:golden_carrot", gold_nugget, gold_nugget, gold_nugget, gold_nugget, carrot, gold_nugget, gold_nugget, gold_nugget, gold_nugget); addItem("minecraft:glistering_melon_slice", gold_nugget, gold_nugget, gold_nugget, gold_nugget, melon_slice, gold_nugget, gold_nugget, gold_nugget, gold_nugget); addItem("minecraft:redstone_lamp", air, redstone, air, redstone, glowstone, redstone, air, redstone, air); addItem("minecraft:writable_book", book, feather, ink_sac, air, air, air, air, air, air); addItem("minecraft:powered_rail", gold_ingot, air, gold_ingot, gold_ingot, stick, gold_ingot, gold_ingot, redstone, gold_ingot); addItem("minecraft:stick", air, iron_ingot, air, air, iron_ingot, air, air, air, air); addItem("minecraft:wooden_pickaxe", oak_planks, oak_planks, oak_planks, air, stick, air, air, stick, air); addItem("minecraft:iron_pickaxe", iron_ingot, iron_ingot, iron_ingot, air, stick, air, air, stick, air); addItem("minecraft:golden_pickaxe", gold_ingot, gold_ingot, gold_ingot, air, stick, air, air, stick, air); addItem("minecraft:wooden_hoe", oak_planks, oak_planks, air, air, stick, air, air, stick, air); addItem("minecraft:diamond_hoe", diamond, diamond, air, air, stick, air, air, stick, air); addItem("minecraft:golden_hoe", gold_ingot, gold_ingot, air, air, stick, air, air, stick, air); addItem("minecraft:diamond_chestplate", diamond, air, diamond, diamond, diamond, diamond, diamond, diamond, diamond); addItem("minecraft:iron_chestplate", iron_ingot, air, iron_ingot, iron_ingot, iron_ingot, iron_ingot, iron_ingot, iron_ingot, iron_ingot); addItem("minecraft:golden_boots", air, air, air, gold_ingot, air, gold_ingot, gold_ingot, air, gold_ingot); //Page3 addItem("minecraft:diamond_boots", air, air, air, diamond, air, diamond, diamond, air, diamond); addItem("minecraft:iron_helmet", iron_ingot, iron_ingot, iron_ingot, iron_ingot, air, iron_ingot, air, air, air); addItem("minecraft:iron_leggings", iron_ingot, iron_ingot, iron_ingot, iron_ingot, air, iron_ingot, iron_ingot, air, iron_ingot); addItem("minecraft:iron_boots", air, air, air, iron_ingot, air, iron_ingot, iron_ingot, air, iron_ingot); addItem("minecraft:golden_leggings", iron_ingot, iron_ingot, iron_ingot, iron_ingot, air, iron_ingot, iron_ingot, air, iron_ingot); addItem("minecraft:golden_helmet", iron_ingot, air, iron_ingot, iron_ingot, iron_ingot, iron_ingot, air, air, air); addItem("minecraft:golden_chestplate", iron_ingot, air, iron_ingot, iron_ingot, iron_ingot, iron_ingot, iron_ingot, iron_ingot, iron_ingot); gosub("setstart"); for(team = 0; team < numberofteams; team++) { map.add(playersinteam, team, 0); map.add(teamidtolist, team, list.new()); } goto("simplelobby"); @specificLobbyHandling if(event == "player_join") { list.add(waiters, player.getUuid(player)); 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; } if(event == "player_giveup" || event == "player_logout") { list.remove(waiters, player.getUuid(player)); return; } if(event == "block_click") { player_uuid = player.getUuid(player); if(map.contains(join_blocks, block_loc)) { newteam = map.get(join_blocks, block_loc); newteamlist = map.get(teamidtolist, newteam); if(list.contains(newteamlist, player_uuid)) { msg.prefix(player, gamename, "You already choosed a team."); return; } if(list.getSize(newteamlist) >= teamsize) { msg.prefix(player, gamename, "Not enough space in this team."); return; } list.remove(waiters, player_uuid); yetteam = map.get(players, player_uuid); if(yetteam != null) { yetteamlist = map.get(teamidtolist, yetteam); list.remove(yetteamlist, player_uuid); map.add(playersinteam, yetteam, map.get(playersinteam, yetteam) - 1); } map.add(playersinteam, newteam, map.get(playersinteam, newteam) + 1); list.add(newteamlist, player_uuid); map.add(players, player_uuid, newteam); msg.prefix(player, gamename, concat("You joined the ", map.get(teamcolortext, newteam), " §rteam.")); entity.setName(player, concat(map.get(colorcodes, newteam), player.getName(player))); } } return; @finalstart player_list = minigame.getPlayers(script_id); entity.removeAll("net.minecraft.entity.item.ItemEntity", middleloc, radius); while(list.getSize(waiters) != 0) { team = getTeamWithLowestPeople(teamidtolist, numberofteams); teamlist = map.get(teamidtolist, team); p_uuid = list.getIndex(waiters, 0); map.add(playersinteam, team, map.get(playersinteam, team) + 1); list.add(teamlist, p_uuid); list.remove(waiters, p_uuid); map.add(players, p_uuid, team); entity.setName(player.get(p_uuid), concat(map.get(colorcodes, team), player.getName(p_uuid))); } event.load("player_post_respawn"); event.load("item_air_click"); event.load("entity_click"); event.load("inv_click"); event.load("human_hurt"); for(i = 0; i < list.getSize(player_list); i++) { p_uuid = list.getIndex(player_list, i); team = map.get(players, p_uuid); p = player.get(p_uuid); msg.prefix(p, gamename, "The game has started."); entity.teleport(p, map.get(spawn_locs, team)); //Recipe-Menus für jeden Spieler erstellen menu = inv.new("222222222222222222222222222222222222222222222000000022"); map.add(recipe_menus, p_uuid, menu); //Gamemode und Fly deaktivieren if(player.isSurvival(p)) { if(player.isAdventure(p)) { player.setGamemode(p, "survival"); } } else { player.setGamemode(p, "survival"); } if(player.hasFly(p)) { player.setFly(p, false); } player.clearInventory(p); //Building-Perms entfernen if(perm.has(p, "plot.bypass")) { perm.unregisterPlayer(p_uuid, 1); perm.unregisterPlayer(p_uuid, 15); list.add(removed_perms, p_uuid); } } humans_list = getAllEntites(); resetSigns(); resetFrames(); resetContainers(); for(team = 0; team < numberofteams; team++) { teamsize = map.get(playersinteam, team); if(teamsize != 0) { list.add(allteams, team); map.add(points, team, 0); } } //Sales erstellen for(i = 0; i < list.getSize(allteams); i++) { team = list.getIndex(allteams, i); step = list.getSize(sell_frame_locs) / numberofteams; index = team * step; direction = map.get(sell_frame_directions, team); frame_loc = list.getIndex(sell_frame_locs, index); entity = list.getIndex(humans_list, index); entity.removeAll("net.minecraft.entity.item.ItemFrameEntity", frame_loc, 1.5); item = getItem(getRandomIndex()); entity.spawnItemFrame(frame_loc, direction, item); map.add(sales_map, entity, item); time = math.random(30, 60); entity.setName(entity, text.number(time)); } updateDisplay(); singleteam = false; if(list.getSize(allteams) == 1) { singleteam = true; } @loop if(--seconds < 0) { minutes--; seconds = 59; } if(seconds < 10) { minigame.displayAll(1, concat("§aTime left: §r", text.number(minutes), ":0", text.number(seconds))); } else { minigame.displayAll(1, concat("§aTime left: §r", text.number(minutes), ":", text.number(seconds))); } if(minutes == 0 && seconds == 30) { minigame.speakAll(gamename, "The shops are closing in 30 seconds."); for(i = 0; i < list.getSize(player_list); i++) { p = player.get(list.getIndex(player_list, i)); sound.spawnForPlayer(p, join_sound, sound_category_ambient); } } elseif(minutes == 0 && seconds == 10) { minigame.speakAll(gamename, "The shops are closing in 10 seconds."); for(i = 0; i < list.getSize(player_list); i++) { p = player.get(list.getIndex(player_list, i)); sound.spawnForPlayer(p, join_sound, sound_category_ambient); } } elseif(minutes == 0 && seconds <= 3) { for(i = 0; i < list.getSize(player_list); i++) { p = player.get(list.getIndex(player_list, i)); sound.spawnForPlayer(p, join_sound, sound_category_ambient); } } if(minutes == 0 && seconds == 0) { max = -1; minigame.msgAll(getSpacer()); for(i = 0; i < list.getSize(allteams); i++) { team = list.getIndex(allteams, i); teampoints = map.get(points, team); if(teampoints > max) { max = teampoints; winning_team = team; winner_list = map.get(teamidtolist, winning_team); } teamlist = map.get(teamidtolist, team); team_string = ""; for(h = 0; h < list.getSize(teamlist); h++) { p_uuid = list.getIndex(teamlist, h); if(team_string == "") { team_string = player.getName(p_uuid); } else { team_string = concat(team_string, " ", player.getName(p_uuid)); } money.addBoost(player.getId(p_uuid), math.round(teampoints / 3)); } minigame.speakAll(gamename, concat(text.number(teampoints), map.get(colorcodes, team), " (", team_string, ")")); } goto("win"); } iter = map.iterator(sales_map); while(hasNext(iter)) { iter_element = next(iter); key = map.getKey(iter_element); time = read.number(entity.getName(key)) - 1; if(time > 0) { entity.setName(key, text.number(time)); } else { index = list.getIndexOf(humans_list, key); location = list.getIndex(sell_frame_locs, index); entity.removeAll("net.minecraft.entity.item.ItemFrameEntity", location, 1.5); step = list.getSize(sell_frame_locs) / numberofteams; team = math.roundDown(index / step); direction = map.get(sell_frame_directions, team); item = getItem(getRandomIndex()); entity.spawnItemFrame(location, direction, item); map.add(sales_map, key, item); time = math.random(30, 60); entity.setName(key, text.number(time)); } } sgoto(20, "loop"); @checkgame wait(); if(event == "living_pre_hurt") { if(!isPlayer(living_entity)) { goto("checkgame"); } player = living_entity; } elseif(event == "human_hurt") { if(!isPlayer(entity)) { goto("checkgame"); } player = entity; } if(player.hasMinigameId(player, script_id)) { ignoreGoto(event); } goto("checkgame"); @block_click if(block.hasTag(wall_signs_tag, block)) { if(block.getSign(block_loc, 0) == "Click here") { if(player.getItemAmount(player, false, emerald) >= 10) { direction = block.property.getValue(block_loc, facing_prop); block.set(block_loc, air); item = getItem(getRandomIndex()); entity.spawnItemFrame(block_loc, direction, item); entity = list.getIndex(humans_list, list.getIndexOf(sell_frame_locs, block_loc)); map.add(sales_map, entity, item); time = math.random(30, 60); entity.setName(entity, text.number(time)); player.removeItem(player, emerald10); } else { msg.prefix(player, gamename, "You need 10 emeralds."); } } } goto("checkgame"); @living_pre_hurt if(isPlayer(living_entity)) { cancel = true; } goto("checkgame"); @block_break @block_place cancel = true; goto("checkgame"); @human_hurt if(isPlayer(entity)) { player = entity; if(map.contains(sales_map, human)) { hand_item = living.getEquip(player, "hand"); aim_item = map.get(sales_map, human); if(item.getType(hand_item) == item.getType(aim_item)) { player_uuid = player.getUuid(player); team = map.get(players, player_uuid); direction = map.get(sell_frame_directions, team); item = getItem(getRandomIndex()); location = list.getIndex(sell_frame_locs, list.getIndexOf(humans_list, human)); entity.removeAll("net.minecraft.entity.item.ItemFrameEntity", location, 1.5); entity.spawnItemFrame(location, direction, item); map.add(sales_map, human, item); time = math.random(30, 60); entity.setName(human, text.number(time)); player.giveItem(player, emerald); player.removeItem(player, aim_item); map.add(points, team, map.get(points, team) + 1); updateDisplay(); msg.prefix(player, gamename, "Thank you §e+§r1 §aSmaragd"); } else { msg.prefix(player, gamename, "Wrong item in your mainhand."); } } } else { if(entity.getName(human) != "Recipes") { msg.prefix(player, gamename, "Shop not unlocked."); } } goto("checkgame"); @inv_click if(inv_name == "Recipes") { player_uuid = player.getUuid(player); team = map.get(players, player_uuid); item_type = item.getType(item); if(item_type == air) { goto("checkgame"); } if(item_type == paper) { name = item.getName(item); if(text.contains(name, "<<") || text.contains(name, ">>")) { page = removeFormat(name); page = text.replace(page, "<<", ""); page = text.replace(page, ">>", ""); page = read.number(page); if(inv_slot == 45) { setRecipePage(player, inv, page); } if(inv_slot == 46) { setRecipePage(player, inv, page); } goto("checkgame"); } } index = getIndexFromItemType(item_type); if(index == null) { goto("checkgame"); } setItemFrames(team, index); } goto("checkgame"); @entity_click if(entity.getType(entity) == "human") { if(entity.getName(entity) == "Recipes") { player_uuid = player.getUuid(player); menu = map.get(recipe_menus, player_uuid); setRecipePage(player, menu, 1); inv.open(menu, player, "Recipes"); } goto("checkgame"); } human = entity; entity = player; goto("human_hurt"); @player_post_respawn player_uuid = player.getUuid(player); team = map.get(players, player_uuid); location = map.get(spawn_locs, team); entity.teleport(player, location); goto("checkgame"); @item_air_click if(hand == "MAIN_HAND") { item = living.getEquip(player, "hand"); } else { item = living.getEquip(player, "offhand"); } if(item.getType(item) == "minecraft:ender_pearl") { cancel = true; } goto("checkgame"); @player_logout @player_giveup minigame.speakAll(gamename, concat("§8", player.getName(player), " §rhas left the game.")); showstats(player, false); player_uuid = player.getUuid(player); //Building-Perms wieder geben if(list.contains(removed_perms, player_uuid)) { list.remove(removed_perms, player_uuid); perm.registerPlayer(player_uuid, 1); perm.registerPlayer(player_uuid, 15); } if(singleteam) { script = script.getFromId(script_id); minigame.kickPlayer(script, player); minigame.term(script, gamesignloc); term(); } team = map.get(players, player_uuid); map.remove(players, player_uuid); script = script.getFromId(script_id); minigame.kickPlayer(script, player); amount = map.get(playersinteam, team) - 1; map.add(playersinteam, team, amount); if(amount <= 0) { list.remove(allteams, team); if(list.getSize(allteams) == 1) { winning_team = list.getIndex(allteams, 0); winner_list = map.get(teamidtolist, winning_team); goto("win"); } } minigame.displayRemoveAll(2 + team); goto("checkgame"); @win team_string = ""; for(h = 0; h < list.getSize(winner_list); h++) { if(team_string == "") { team_string = player.getName(list.getIndex(winner_list, h)); } else { team_string = concat(team_string, " ", player.getName(list.getIndex(winner_list, h))); } } if(!singleteam) { minigame.speakAll( gamename, concat("Team ", map.get(colorcodes, winning_team), "(", team_string, ") §rhas won.")); } for(i = 0; i < list.getSize(player_list); i++) { player_uuid = list.getIndex(player_list, i); p = player.get(player_uuid); team = map.get(players, player_uuid); if(team == winning_team) { showstats(p, true); } else { showstats(p, false); } script = script.getFromId(script_id); minigame.kickPlayer(script, p); } //Building-Perms wieder geben for(i = 0; i < list.getSize(removed_perms); i++) { player_uuid = list.getIndex(removed_perms, i); perm.registerPlayer(player_uuid, 1); perm.registerPlayer(player_uuid, 15); } minigame.kickAllPlayers(script); 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); playedgames = minigame.getPlayed(player_id, $game_short) + 1; minigame.setPlayed(player_id, $game_short, playedgames); player_uuid = player.getUuid(player); team = map.get($players, player_uuid); record = map.get($points, team); if(record < last_record) { record = last_record; } ranking.setPoints($rankingtable, player_id, record); wongames = minigame.getWon(player, "sc"); if(!$singleteam) { if(won) { wongames++; minigame.setWon(player, "sc", wongames); } } minigame.statsHeader(player, $gamename, "§e"); minigame.statsLine(player, "§e", "Max Items", text.number(last_record)); minigame.statsLine(player, "§e", "Played games", text.number(playedgames)); minigame.statsLine(player, "§e", "Won games", text.number(wongames)); if(playedgames != 0) { minigame.statsLine(player, "§e", "Win ratio", concat(text.number(math.roundComma((wongames / playedgames) * 100, 2)), "%")); } } function updateDisplay() { minigame.displayAll(0, $gamename); for(i = 0; i < list.getSize($allteams); i++) { team = list.getIndex($allteams, i); teamlist = map.get($teamidtolist, team); team_string = ""; for(h = 0; h < list.getSize(teamlist); h++) { if(team_string == "") { team_string = player.getName(list.getIndex(teamlist, h)); } else { team_string = concat(team_string, " ", player.getName(list.getIndex(teamlist, h))); } } minigame.displayAll(2 + team, concat("§r", text.number(map.get($points, team)), " ", map.get($colorcodes, team), team_string)); } } function addItem(item, item1, item2, item3, item4, item5, item6, item7, item8, item9) { array = array.new(10); array[0] = item; array[1] = item1; array[2] = item2; array[3] = item3; array[4] = item4; array[5] = item5; array[6] = item6; array[7] = item7; array[8] = item8; array[9] = item9; list.add($items_list, array); } function getRandomIndex() { return math.random(0, list.getSize($items_list) - 1); } function getIndexFromItemType(item_type) { for(i = 0; i < list.getSize($items_list); i++) { array = list.getIndex($items_list, i); if(array[0] == item_type) { return i; } } return null; } function getItem(index) { array = list.getIndex($items_list, index); return read.item(array[0]); } function setItemFrames(team, index) { loc = list.getIndex($frame_locs, team); entity.removeAll("net.minecraft.entity.item.ItemFrameEntity", loc, 3.5); direction = map.get($frame_directions, team); array = list.getIndex($items_list, index); entity.spawnItemFrame(loc, direction, read.item(array[0])); if(direction == "north") { entity.spawnItemFrame(loc.mod(loc, 1, -1, 0), direction, read.item(array[1])); entity.spawnItemFrame(loc.mod(loc, 0, -1, 0), direction, read.item(array[2])); entity.spawnItemFrame(loc.mod(loc, -1, -1, 0), direction, read.item(array[3])); entity.spawnItemFrame(loc.mod(loc, 1, -2, 0), direction, read.item(array[4])); entity.spawnItemFrame(loc.mod(loc, 0, -2, 0), direction, read.item(array[5])); entity.spawnItemFrame(loc.mod(loc, -1, -2, 0), direction, read.item(array[6])); entity.spawnItemFrame(loc.mod(loc, 1, -3, 0), direction, read.item(array[7])); entity.spawnItemFrame(loc.mod(loc, 0, -3, 0), direction, read.item(array[8])); entity.spawnItemFrame(loc.mod(loc, -1, -3, 0), direction, read.item(array[9])); } elseif(direction == "east") { entity.spawnItemFrame(loc.mod(loc, 0, -1, -1), direction, read.item(array[1])); entity.spawnItemFrame(loc.mod(loc, 0, -1, 0), direction, read.item(array[2])); entity.spawnItemFrame(loc.mod(loc, 0, -1, 1), direction, read.item(array[3])); entity.spawnItemFrame(loc.mod(loc, 0, -2, -1), direction, read.item(array[4])); entity.spawnItemFrame(loc.mod(loc, 0, -2, 0), direction, read.item(array[5])); entity.spawnItemFrame(loc.mod(loc, 0, -2, 1), direction, read.item(array[6])); entity.spawnItemFrame(loc.mod(loc, 0, -3, -1), direction, read.item(array[7])); entity.spawnItemFrame(loc.mod(loc, 0, -3, 0), direction, read.item(array[8])); entity.spawnItemFrame(loc.mod(loc, 0, -3, 1), direction, read.item(array[9])); } elseif(direction == "south") { entity.spawnItemFrame(loc.mod(loc, -1, -1, 0), direction, read.item(array[1])); entity.spawnItemFrame(loc.mod(loc, 0, -1, 0), direction, read.item(array[2])); entity.spawnItemFrame(loc.mod(loc, 1, -1, 0), direction, read.item(array[3])); entity.spawnItemFrame(loc.mod(loc, -1, -2, 0), direction, read.item(array[4])); entity.spawnItemFrame(loc.mod(loc, 0, -2, 0), direction, read.item(array[5])); entity.spawnItemFrame(loc.mod(loc, 1, -2, 0), direction, read.item(array[6])); entity.spawnItemFrame(loc.mod(loc, -1, -3, 0), direction, read.item(array[7])); entity.spawnItemFrame(loc.mod(loc, 0, -3, 0), direction, read.item(array[8])); entity.spawnItemFrame(loc.mod(loc, 1, -3, 0), direction, read.item(array[9])); } elseif(direction == "west") { entity.spawnItemFrame(loc.mod(loc, 0, -1, 1), direction, read.item(array[1])); entity.spawnItemFrame(loc.mod(loc, 0, -1, 0), direction, read.item(array[2])); entity.spawnItemFrame(loc.mod(loc, 0, -1, -1), direction, read.item(array[3])); entity.spawnItemFrame(loc.mod(loc, 0, -2, 1), direction, read.item(array[4])); entity.spawnItemFrame(loc.mod(loc, 0, -2, 0), direction, read.item(array[5])); entity.spawnItemFrame(loc.mod(loc, 0, -2, -1), direction, read.item(array[6])); entity.spawnItemFrame(loc.mod(loc, 0, -3, 1), direction, read.item(array[7])); entity.spawnItemFrame(loc.mod(loc, 0, -3, 0), direction, read.item(array[8])); entity.spawnItemFrame(loc.mod(loc, 0, -3, -1), direction, read.item(array[9])); } } function resetSigns() { step = list.getSize($sell_frame_locs) / $numberofteams; team = 0; counter = 0; for(i = 0; i < list.getSize($sell_frame_locs); i++) { if(counter != 0) { //Erste Locs werden übersprungen. Kein Schild platzieren = Freigeschalteter Shop loc = list.getIndex($sell_frame_locs, i); entity.removeAll("net.minecraft.entity.item.ItemFrameEntity", loc, 1.5); direction = map.get($sell_frame_directions, team); block.set(loc, concat("minecraft:oak_wall_sign[facing=", direction, "]")); block.setSign(loc, 0, "Click here"); block.setSign(loc, 1, "to unlock for"); block.setSign(loc, 2, "§a10 §rEmerald"); block.setSign(loc, 3, ">> >> >>"); } if(++counter == step) { counter = 0; team++; } } } function resetFrames() { for(i = 0; i < list.getSize($frame_locs); i++) { loc = list.getIndex($frame_locs, i); entity.removeAll("net.minecraft.entity.item.ItemFrameEntity", loc, 3.5); direction = map.get($frame_directions, i); entity.spawnItemFrame(loc, direction, $air_item); entity.spawnItemFrame(loc.mod(loc, 0, -1, 0), direction, $air_item); entity.spawnItemFrame(loc.mod(loc, 0, -2, 0), direction, $air_item); entity.spawnItemFrame(loc.mod(loc, 0, -3, 0), direction, $air_item); if(direction == "north" || direction == "south") { entity.spawnItemFrame(loc.mod(loc, 1, -1, 0), direction, $air_item); entity.spawnItemFrame(loc.mod(loc, -1, -1, 0), direction, $air_item); entity.spawnItemFrame(loc.mod(loc, 1, -2, 0), direction, $air_item); entity.spawnItemFrame(loc.mod(loc, -1, -2, 0), direction, $air_item); entity.spawnItemFrame(loc.mod(loc, 1, -3, 0), direction, $air_item); entity.spawnItemFrame(loc.mod(loc, -1, -3, 0), direction, $air_item); } if(direction == "east" || direction == "west") { entity.spawnItemFrame(loc.mod(loc, 0, -1, 1), direction, $air_item); entity.spawnItemFrame(loc.mod(loc, 0, -1, -1), direction, $air_item); entity.spawnItemFrame(loc.mod(loc, 0, -2, 1), direction, $air_item); entity.spawnItemFrame(loc.mod(loc, 0, -2, -1), direction, $air_item); entity.spawnItemFrame(loc.mod(loc, 0, -3, 1), direction, $air_item); entity.spawnItemFrame(loc.mod(loc, 0, -3, -1), direction, $air_item); } } } function resetContainers() { //1.Kiste for(i = 0; i < list.getSize($chest_locs1); i++) { loc = list.getIndex($chest_locs1, i); block.clone(loc.mod(loc, 0, -3, 0), loc); } //2.Kiste for(i = 0; i < list.getSize($chest_locs2); i++) { loc = list.getIndex($chest_locs2, i); block.clone(loc.mod(loc, 0, -3, 0), loc); } //Ofen for(i = 0; i < list.getSize($furnace_locs); i++) { loc = list.getIndex($furnace_locs, i); block.clone(loc.mod(loc, 0, -3, 0), loc); } } function setRecipePage(player, menu, page) { size = list.getSize($items_list); max_page = math.roundUp(size / 45); if(page > max_page) { return; } if(page > 1) { inv.setItem(menu, 45, read.item("minecraft:paper", 1, concat("§e", text.number(page - 1), " <<"))); } else { inv.setItem(menu, 45, $air_item); } if(page < max_page) { inv.setItem(menu, 46, read.item("minecraft:paper", 1, concat("§e>> ", text.number(page + 1)))); } else { inv.setItem(menu, 46, $air_item); } max_index = size - 1; for(i = 0; i < 45; i++) { list_index = i + 45 * (page - 1); if(list_index > max_index) { inv.setItem(menu, i, $air_item); } else { array = list.getIndex($items_list, list_index); inv.setItem(menu, i, read.item(array[0])); } } inv.update(player); } function getAllEntites() { humans_list = list.new(); for(i = 0; i < list.getSize($humans_locs); i++) { location = list.getIndex($humans_locs, i); entity = entity.get(location, 10, "me.km.entities.EntityHuman"); list.add(humans_list, entity); entity.setName(entity, "Shop"); } return humans_list; }