shoppingchaos.txt 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863
  1. rankingtable = "shoppingranks";
  2. specific_lobby_handling = true;
  3. air = "minecraft:air";
  4. air_item = read.item(air);
  5. emerald = read.item("minecraft:emerald");
  6. emerald10 = read.item("minecraft:emerald", 10);
  7. gamename = "§eShoppingChaos";
  8. start_sound = sound.get("minecraft:block.note_block.harp");
  9. wall_signs_tag = block.getTag("minecraft:wall_signs");
  10. facing_prop = block.getProperty("horizontal_facing");
  11. players = map.new(); //Alle player_uuids mit Verweis auf die Team-Nr
  12. playersinteam = map.new(); //Anzahl der Spieler im Team
  13. teamidtolist = map.new(); //Team-Nr mit Verweis auf die Spielerlisten
  14. allteams = list.new(); //Alle Teams, die noch im Spiel sind
  15. items_list = list.new(); //Array-List: Alle Items mit Rezepten
  16. points = map.new(); //Punktestand der Teams
  17. sales_map = map.new(); //Key Entity. Value Item
  18. recipe_menus = map.new(); //Rezept-Menüs für jeden Spieler
  19. removed_perms = list.new(); //Spieler-Uuids, denen Building-Perms entfernt wurden
  20. waiters = list.new(); //Spieler in der Lobby ohne Teamzugehörigkeit
  21. colorcodes = map.new();
  22. map.add(colorcodes, 0, "§9");
  23. map.add(colorcodes, 1, "§c");
  24. map.add(colorcodes, 2, "§e");
  25. map.add(colorcodes, 3, "§2");
  26. teamcolortext = map.new();
  27. map.add(teamcolortext, 0, "§9blue");
  28. map.add(teamcolortext, 1, "§cred");
  29. map.add(teamcolortext, 2, "§eyellow");
  30. map.add(teamcolortext, 3, "§2green");
  31. iron_block = "minecraft:iron_block";
  32. iron_ingot = "minecraft:iron_ingot";
  33. gold_ingot = "minecraft:gold_ingot";
  34. diamond = "minecraft:diamond";
  35. ink_sac = "minecraft:ink_sac";
  36. book = "minecraft:book";
  37. stick = "minecraft:stick";
  38. oak_planks = "minecraft:oak_planks";
  39. quartz_block = "minecraft:quartz_block";
  40. glass = "minecraft:glass";
  41. apple = "minecraft:apple";
  42. cobble = "minecraft:cobblestone";
  43. redstone = "minecraft:redstone";
  44. glowstone = "minecraft:glowstone";
  45. gold_nugget = "minecraft:gold_nugget";
  46. obsidian = "minecraft:obsidian";
  47. ender_eye = "minecraft:ender_eye";
  48. melon_slice = "minecraft:melon_slice";
  49. carrot = "minecraft:carrot";
  50. chest = "minecraft:chest";
  51. coal = "minecraft:coal";
  52. string = "minecraft:string";
  53. furnace = "minecraft:furnace";
  54. compass = "minecraft:compass";
  55. blaze_powder = "minecraft:blaze_powder";
  56. slime_ball = "minecraft:slime_ball";
  57. blaze_rod = "minecraft:blaze_rod";
  58. sugar_cane = "minecraft:sugar_cane";
  59. sugar = "minecraft:sugar";
  60. milk = "minecraft:milk_bucket";
  61. egg = "minecraft:egg";
  62. white_wool= "minecraft:white_wool";
  63. wheat = "minecraft:wheat";
  64. gunpowder = "minecraft:gunpowder";
  65. sand = "minecraft:sand";
  66. ender_pearl = "minecraft:ender_pearl";
  67. leather = "minecraft:leather";
  68. stone = "minecraft:stone";
  69. smooth_stone = "minecraft:smooth_stone";
  70. bow = "minecraft:bow";
  71. flint = "minecraft:flint";
  72. feather = "minecraft:feather";
  73. pumpkin = "minecraft:pumpkin";
  74. sugar = "minecraft:sugar";
  75. egg = "minecraft:egg";
  76. beef = "minecraft:beef";
  77. porkchop = "minecraft:porkchop";
  78. paper = "minecraft:paper";
  79. brown_mushroom = "minecraft:brown_mushroom";
  80. red_mushroom = "minecraft:red_mushroom";
  81. bowl = "minecraft:bowl";
  82. redstone_torch = "minecraft:redstone_torch";
  83. quartz = "minecraft:quartz";
  84. oak_slab = "minecraft:oak_slab";
  85. cod = "minecraft:cod";
  86. piston = "minecraft:piston";
  87. tnt = "minecraft:tnt";
  88. minecart = "minecraft:minecart";
  89. stone_bricks = "minecraft:stone_bricks";
  90. stone_pressure_plate = "minecraft:stone_pressure_plate";
  91. addItem("minecraft:rail", iron_ingot, air, iron_ingot, iron_ingot, stick, iron_ingot, iron_ingot, air, iron_ingot);
  92. addItem("minecraft:oak_fence", air, air, air, oak_planks, stick, oak_planks, oak_planks, stick, oak_planks);
  93. addItem("minecraft:glass_bottle", glass, air, glass, air, glass, air, air, air, air);
  94. addItem("minecraft:dropper", cobble, cobble, cobble, cobble, air, cobble, cobble, redstone, cobble);
  95. addItem("minecraft:iron_sword", air, iron_ingot, air, air, iron_ingot, air, air, stick, air);
  96. addItem("minecraft:ladder", stick, air, stick, stick, stick, stick, stick, air, stick);
  97. addItem("minecraft:minecart", air, air, air, iron_ingot, air, iron_ingot, iron_ingot, iron_ingot, iron_ingot);
  98. addItem("minecraft:hopper", iron_ingot, air, iron_ingot, iron_ingot, chest, iron_ingot, air, iron_ingot, air);
  99. addItem("minecraft:redstone_torch", air, air, air, air, redstone, air, air, stick, air);
  100. addItem("minecraft:torch", air, air, air, air, coal, air, air, stick, air);
  101. addItem("minecraft:bow", air, stick, string, stick, air, string, air, stick, string);
  102. addItem("minecraft:cobblestone_wall", air, air, air, cobble, cobble, cobble, cobble, cobble, cobble);
  103. addItem("minecraft:stone", air, air, air, furnace, cobble, air, air, air, air);
  104. addItem("minecraft:oak_door", oak_planks, oak_planks, air, oak_planks, oak_planks, air, oak_planks, oak_planks, air);
  105. addItem("minecraft:oak_fence_gate", air, air, air, stick, oak_planks, stick, stick, oak_planks, stick);
  106. addItem("minecraft:stone_pressure_plate", air, air, air, stone, stone, air, air, air, air);
  107. addItem("minecraft:oak_pressure_plate", air, air, air, oak_planks, oak_planks, air, air, air, air);
  108. addItem("minecraft:oak_trapdoor", air, air, air, oak_planks, oak_planks, oak_planks, oak_planks, oak_planks, oak_planks);
  109. addItem("minecraft:bucket", iron_ingot, air, iron_ingot, air, iron_ingot, air, air, air, air);
  110. addItem("minecraft:iron_bars", iron_ingot, iron_ingot, iron_ingot, iron_ingot, iron_ingot, iron_ingot, air, air, air);
  111. addItem("minecraft:oak_sign", oak_planks, oak_planks, oak_planks, oak_planks, oak_planks, oak_planks, air, stick, air);
  112. addItem("minecraft:shears", air, iron_ingot, air, iron_ingot, air, air, air, air, air);
  113. addItem("minecraft:fishing_rod", air, air, stick, air, stick, string, stick, air, string);
  114. addItem("minecraft:compass", air, iron_ingot, air, iron_ingot, redstone, iron_ingot, air, iron_ingot, air);
  115. addItem("minecraft:oak_boat", oak_planks, air, oak_planks, oak_planks, oak_planks, oak_planks, air, air, air);
  116. addItem("minecraft:bowl", oak_planks, air, oak_planks, air, oak_planks, air, air, air, air);
  117. addItem("minecraft:white_wool", string, string, air, string, string, air, air, air, air);
  118. addItem("minecraft:wooden_sword", air, oak_planks, air, air, oak_planks, air, air, stick, air);
  119. addItem("minecraft:tripwire_hook", air, iron_ingot, air, air, stick, air, air, oak_planks, air);
  120. addItem("minecraft:chest_minecart", air, chest, air, air, minecart, air, air, air, air);
  121. addItem("minecraft:iron_door", iron_ingot, iron_ingot, air, iron_ingot, iron_ingot, air, iron_ingot, iron_ingot, air);
  122. addItem("minecraft:smooth_stone_slab", smooth_stone, smooth_stone, smooth_stone, air, air, air, air, air, air);
  123. addItem("minecraft:activator_rail", iron_ingot, stick, iron_ingot, iron_ingot, redstone_torch, iron_ingot, iron_ingot, stick, iron_ingot);
  124. addItem("minecraft:detector_rail", iron_ingot, air, iron_ingot, iron_ingot, stone_pressure_plate, iron_ingot, iron_ingot, redstone, iron_ingot);
  125. addItem("minecraft:dispenser", cobble, cobble, cobble, cobble, bow, cobble, cobble, redstone, cobble);
  126. addItem("minecraft:piston", oak_planks, oak_planks, oak_planks, cobble, iron_ingot, cobble, cobble, redstone, cobble);
  127. addItem("minecraft:repeater", redstone_torch, redstone, redstone_torch, stone, stone, stone, air, air, air);
  128. addItem("minecraft:comparator", air, redstone_torch, air, redstone_torch, quartz, redstone_torch, stone, stone, stone);
  129. addItem("minecraft:heavy_weighted_pressure_plate", air, air, air, iron_ingot, iron_ingot, air, air, air, air);
  130. addItem("minecraft:arrow", air, flint, air, air, stick, air, air, feather, air);
  131. addItem("minecraft:bookshelf", oak_planks, oak_planks, oak_planks, paper, paper, paper, oak_planks, oak_planks, oak_planks);
  132. addItem("minecraft:mushroom_stew", brown_mushroom, red_mushroom, bowl, air, air, air, air, air, air);
  133. addItem("minecraft:pumpkin_pie", pumpkin, sugar, egg, air, air, air, air, air, air);
  134. addItem("minecraft:cooked_beef", air, air, air, furnace, beef, air, air, air, air);
  135. addItem("minecraft:cooked_porkchop", air, air, air, furnace, porkchop, air, air, air, air);
  136. //Page2
  137. addItem("minecraft:book", paper, paper, paper, leather, air, air, air, air, air);
  138. addItem("minecraft:map", paper, paper, paper, paper, compass, paper, paper, paper, paper);
  139. addItem("minecraft:ender_eye", ender_pearl, blaze_powder, air, air, air, air, air, air, air);
  140. addItem("minecraft:lead", air, string, string, air, slime_ball, string, string, air, air);
  141. addItem("minecraft:stone_brick_slab", stone_bricks, stone_bricks, stone_bricks, air, air, air, air, air, air);
  142. addItem("minecraft:brewing_stand", air, air, air, air, blaze_rod, air, cobble, cobble, cobble);
  143. addItem("minecraft:leather_helmet", leather, leather, leather, leather, air, leather, air, air, air);
  144. addItem("minecraft:leather_chestplate", leather, air, leather, leather, leather, leather, leather, leather, leather);
  145. addItem("minecraft:leather_leggings", leather, leather, leather, leather, air, leather, leather, air, leather);
  146. addItem("minecraft:leather_boots", air, air, air, leather, air, leather, leather, air, leather);
  147. addItem("minecraft:cauldron", iron_ingot, air, iron_ingot, iron_ingot, air, iron_ingot, iron_ingot, iron_ingot, iron_ingot);
  148. addItem("minecraft:clock", air, gold_ingot, air, gold_ingot, redstone, gold_ingot, air, gold_ingot, air);
  149. addItem("minecraft:paper", sugar_cane, sugar_cane, sugar_cane, air, air, air, air, air, air);
  150. addItem("minecraft:tnt", gunpowder, sand, gunpowder, sand, gunpowder, sand, gunpowder, sand, gunpowder);
  151. addItem("minecraft:magma_cream", air, air, air, slime_ball, blaze_powder, air, air, air, air);
  152. addItem("minecraft:bread", air, air, air, wheat, wheat, wheat, air, air, air);
  153. addItem("minecraft:white_bed", air, air, air, white_wool, white_wool, white_wool, oak_planks, oak_planks, oak_planks);
  154. addItem("minecraft:cake", milk, milk, milk, sugar, egg, sugar, wheat, wheat, wheat);
  155. addItem("minecraft:cooked_cod", air, air, air, furnace, cod, air, air, air, air);
  156. addItem("minecraft:tnt_minecart", air, air, air, air, tnt, air, air, minecart, air);
  157. addItem("minecraft:melon", melon_slice, melon_slice, melon_slice, melon_slice, melon_slice, melon_slice, melon_slice, melon_slice, melon_slice);
  158. addItem("minecraft:hay_block", wheat, wheat, wheat, wheat, wheat, wheat, wheat, wheat, wheat);
  159. addItem("minecraft:ender_chest", obsidian, obsidian, obsidian, obsidian, ender_eye, obsidian, obsidian, obsidian, obsidian);
  160. addItem("minecraft:sticky_piston", air, air, air, air, slime_ball, air, air, piston, air);
  161. addItem("minecraft:daylight_detector", glass, glass, glass, quartz, quartz, quartz, oak_slab, oak_slab, oak_slab);
  162. addItem("minecraft:golden_apple", gold_ingot, gold_ingot, gold_ingot, gold_ingot, apple, gold_ingot, gold_ingot, gold_ingot, gold_ingot);
  163. addItem("minecraft:jukebox", oak_planks, oak_planks, oak_planks, oak_planks, diamond, oak_planks, oak_planks, oak_planks, oak_planks);
  164. addItem("minecraft:anvil", iron_block, iron_block, iron_block, air, iron_ingot, air, iron_ingot, iron_ingot, iron_ingot);
  165. addItem("minecraft:quartz_stairs", quartz_block, air, air, quartz_block, quartz_block, air, quartz_block, quartz_block, quartz_block);
  166. addItem("minecraft:enchanting_table", air, book, air, diamond, obsidian, diamond, obsidian, obsidian, obsidian);
  167. addItem("minecraft:golden_carrot", gold_nugget, gold_nugget, gold_nugget, gold_nugget, carrot, gold_nugget, gold_nugget, gold_nugget, gold_nugget);
  168. addItem("minecraft:glistering_melon_slice", gold_nugget, gold_nugget, gold_nugget, gold_nugget, melon_slice, gold_nugget, gold_nugget, gold_nugget, gold_nugget);
  169. addItem("minecraft:redstone_lamp", air, redstone, air, redstone, glowstone, redstone, air, redstone, air);
  170. addItem("minecraft:writable_book", book, feather, ink_sac, air, air, air, air, air, air);
  171. addItem("minecraft:powered_rail", gold_ingot, air, gold_ingot, gold_ingot, stick, gold_ingot, gold_ingot, redstone, gold_ingot);
  172. addItem("minecraft:stick", air, iron_ingot, air, air, iron_ingot, air, air, air, air);
  173. addItem("minecraft:wooden_pickaxe", oak_planks, oak_planks, oak_planks, air, stick, air, air, stick, air);
  174. addItem("minecraft:iron_pickaxe", iron_ingot, iron_ingot, iron_ingot, air, stick, air, air, stick, air);
  175. addItem("minecraft:golden_pickaxe", gold_ingot, gold_ingot, gold_ingot, air, stick, air, air, stick, air);
  176. addItem("minecraft:wooden_hoe", oak_planks, oak_planks, air, air, stick, air, air, stick, air);
  177. addItem("minecraft:diamond_hoe", diamond, diamond, air, air, stick, air, air, stick, air);
  178. addItem("minecraft:golden_hoe", gold_ingot, gold_ingot, air, air, stick, air, air, stick, air);
  179. addItem("minecraft:diamond_chestplate", diamond, air, diamond, diamond, diamond, diamond, diamond, diamond, diamond);
  180. addItem("minecraft:iron_chestplate", iron_ingot, air, iron_ingot, iron_ingot, iron_ingot, iron_ingot, iron_ingot, iron_ingot, iron_ingot);
  181. addItem("minecraft:golden_boots", air, air, air, gold_ingot, air, gold_ingot, gold_ingot, air, gold_ingot);
  182. //Page3
  183. addItem("minecraft:diamond_boots", air, air, air, diamond, air, diamond, diamond, air, diamond);
  184. addItem("minecraft:iron_helmet", iron_ingot, iron_ingot, iron_ingot, iron_ingot, air, iron_ingot, air, air, air);
  185. addItem("minecraft:iron_leggings", iron_ingot, iron_ingot, iron_ingot, iron_ingot, air, iron_ingot, iron_ingot, air, iron_ingot);
  186. addItem("minecraft:iron_boots", air, air, air, iron_ingot, air, iron_ingot, iron_ingot, air, iron_ingot);
  187. addItem("minecraft:golden_leggings", iron_ingot, iron_ingot, iron_ingot, iron_ingot, air, iron_ingot, iron_ingot, air, iron_ingot);
  188. addItem("minecraft:golden_helmet", iron_ingot, air, iron_ingot, iron_ingot, iron_ingot, iron_ingot, air, air, air);
  189. addItem("minecraft:golden_chestplate", iron_ingot, air, iron_ingot, iron_ingot, iron_ingot, iron_ingot, iron_ingot, iron_ingot, iron_ingot);
  190. gosub("setstart");
  191. for(team = 0; team < numberofteams; team++) {
  192. map.add(playersinteam, team, 0);
  193. map.add(teamidtolist, team, list.new());
  194. }
  195. goto("simplelobby");
  196. @specificLobbyHandling
  197. if(event == "player_join") {
  198. list.add(waiters, player.getUuid(player));
  199. display.add(player, 0, gamename);
  200. display.add(player, 1, "§7Map:");
  201. display.add(player, 2, "§3", mapname);
  202. return;
  203. }
  204. if(event == "player_giveup" || event == "player_logout") {
  205. list.remove(waiters, player.getUuid(player));
  206. return;
  207. }
  208. if(event == "block_click") {
  209. player_uuid = player.getUuid(player);
  210. if(map.contains(join_blocks, block_loc)) {
  211. newteam = map.get(join_blocks, block_loc);
  212. newteamlist = map.get(teamidtolist, newteam);
  213. if(list.contains(newteamlist, player_uuid)) {
  214. speakPrefix(player, gamename, "You already choosed a team.");
  215. return;
  216. }
  217. if(list.getSize(newteamlist) >= teamsize) {
  218. speakPrefix(player, gamename, "Not enough space in this team.");
  219. return;
  220. }
  221. list.remove(waiters, player_uuid);
  222. yetteam = map.get(players, player_uuid);
  223. if(yetteam != null) {
  224. yetteamlist = map.get(teamidtolist, yetteam);
  225. list.remove(yetteamlist, player_uuid);
  226. map.add(playersinteam, yetteam, map.get(playersinteam, yetteam) - 1);
  227. }
  228. map.add(playersinteam, newteam, map.get(playersinteam, newteam) + 1);
  229. list.add(newteamlist, player_uuid);
  230. map.add(players, player_uuid, newteam);
  231. speakPrefix(player, gamename, concat("You joined the ", map.get(teamcolortext, newteam), " §rteam."));
  232. entity.setName(player, concat(map.get(colorcodes, newteam), player.getName(player)));
  233. }
  234. }
  235. return;
  236. @finalstart
  237. player_list = minigame.getPlayers(script_id);
  238. entity.removeAll("net.minecraft.entity.item.ItemEntity", middleloc, radius);
  239. while(list.getSize(waiters) != 0) {
  240. team = getTeamWithLowestPeople(teamidtolist, numberofteams);
  241. teamlist = map.get(teamidtolist, team);
  242. p_uuid = list.getIndex(waiters, 0);
  243. map.add(playersinteam, team, map.get(playersinteam, team) + 1);
  244. list.add(teamlist, p_uuid);
  245. list.remove(waiters, p_uuid);
  246. map.add(players, p_uuid, team);
  247. entity.setName(player.get(p_uuid), concat(map.get(colorcodes, team), player.getName(p_uuid)));
  248. }
  249. event.load("player_post_respawn");
  250. event.load("item_air_click");
  251. event.load("entity_click");
  252. event.load("inv_click");
  253. event.load("human_hurt");
  254. for(i = 0; i < list.getSize(player_list); i++) {
  255. p_uuid = list.getIndex(player_list, i);
  256. team = map.get(players, p_uuid);
  257. p = player.get(p_uuid);
  258. speakPrefix(p, gamename, "The game has started.");
  259. entity.teleport(p, map.get(spawn_locs, team));
  260. //Recipe-Menus für jeden Spieler erstellen
  261. menu = inv.new("222222222222222222222222222222222222222222222000000022");
  262. map.add(recipe_menus, p_uuid, menu);
  263. //Gamemode und Fly deaktivieren
  264. if(player.isSurvival(p)) {
  265. if(player.isAdventure(p)) {
  266. player.setGamemode(p, "survival");
  267. }
  268. } else {
  269. player.setGamemode(p, "survival");
  270. }
  271. if(player.hasFly(p)) {
  272. player.setFly(p, false);
  273. }
  274. player.clearInventory(p);
  275. //Building-Perms entfernen
  276. if(perm.has(p, "plot.bypass")) {
  277. perm.unregisterPlayer(p_uuid, 1);
  278. perm.unregisterPlayer(p_uuid, 15);
  279. list.add(removed_perms, p_uuid);
  280. }
  281. }
  282. humans_list = getAllEntites();
  283. resetSigns();
  284. resetFrames();
  285. resetContainers();
  286. for(team = 0; team < numberofteams; team++) {
  287. teamsize = map.get(playersinteam, team);
  288. if(teamsize != 0) {
  289. list.add(allteams, team);
  290. map.add(points, team, 0);
  291. }
  292. }
  293. //Sales erstellen
  294. for(i = 0; i < list.getSize(allteams); i++) {
  295. team = list.getIndex(allteams, i);
  296. step = list.getSize(sell_frame_locs) / numberofteams;
  297. index = team * step;
  298. direction = map.get(sell_frame_directions, team);
  299. frame_loc = list.getIndex(sell_frame_locs, index);
  300. entity = list.getIndex(humans_list, index);
  301. entity.removeAll("net.minecraft.entity.item.ItemFrameEntity", frame_loc, 1.5);
  302. item = getItem(getRandomIndex());
  303. entity.spawnItemFrame(frame_loc, direction, item);
  304. map.add(sales_map, entity, item);
  305. time = math.random(30, 60);
  306. entity.setName(entity, text.number(time));
  307. }
  308. updateDisplay();
  309. if(list.getSize(allteams) == 1) {
  310. singleteam = true;
  311. for(i = 0; i < list.getSize(player_list); i++) {
  312. p = player.get(list.getIndex(player_list, i));
  313. title.setSub(p, "Not ranked");
  314. title.send(p, "§eSingleteam");
  315. }
  316. } else {
  317. singleteam = false;
  318. }
  319. @loop
  320. if(--seconds < 0) {
  321. minutes--;
  322. seconds = 59;
  323. }
  324. if(seconds < 10) {
  325. minigame.displayAll(1, concat("§aTime left: §r", text.number(minutes), ":0", text.number(seconds)));
  326. } else {
  327. minigame.displayAll(1, concat("§aTime left: §r", text.number(minutes), ":", text.number(seconds)));
  328. }
  329. if(minutes == 0 && seconds == 30) {
  330. minigame.speakAll(gamename, "The shops are closing in 30 seconds.");
  331. for(i = 0; i < list.getSize(player_list); i++) {
  332. p = player.get(list.getIndex(player_list, i));
  333. sound.spawnForPlayer(p, join_sound, sound_category_ambient);
  334. }
  335. } elseif(minutes == 0 && seconds == 10) {
  336. minigame.speakAll(gamename, "The shops are closing in 10 seconds.");
  337. for(i = 0; i < list.getSize(player_list); i++) {
  338. p = player.get(list.getIndex(player_list, i));
  339. sound.spawnForPlayer(p, join_sound, sound_category_ambient);
  340. }
  341. } elseif(minutes == 0 && seconds <= 3) {
  342. for(i = 0; i < list.getSize(player_list); i++) {
  343. p = player.get(list.getIndex(player_list, i));
  344. sound.spawnForPlayer(p, join_sound, sound_category_ambient);
  345. }
  346. }
  347. if(minutes == 0 && seconds == 0) {
  348. max = -1;
  349. minigame.msgAll(getSpacer());
  350. for(i = 0; i < list.getSize(allteams); i++) {
  351. team = list.getIndex(allteams, i);
  352. teampoints = map.get(points, team);
  353. if(teampoints > max) {
  354. max = teampoints;
  355. winning_team = team;
  356. winner_list = map.get(teamidtolist, winning_team);
  357. }
  358. teamlist = map.get(teamidtolist, team);
  359. team_string = "";
  360. for(h = 0; h < list.getSize(teamlist); h++) {
  361. if(team_string == "") {
  362. team_string = player.getName(list.getIndex(teamlist, h));
  363. } else {
  364. team_string = concat(team_string, " ", player.getName(list.getIndex(teamlist, h)));
  365. }
  366. }
  367. minigame.speakAll(gamename, concat(text.number(teampoints), map.get(colorcodes, team), " (", team_string, ")"));
  368. }
  369. minigame.msgAll(getSpacer());
  370. goto("win");
  371. }
  372. iter = map.iterator(sales_map);
  373. while(hasNext(iter)) {
  374. iter_element = next(iter);
  375. key = map.getKey(iter_element);
  376. time = read.number(entity.getName(key)) - 1;
  377. if(time > 0) {
  378. entity.setName(key, text.number(time));
  379. } else {
  380. index = list.getIndexOf(humans_list, key);
  381. location = list.getIndex(sell_frame_locs, index);
  382. entity.removeAll("net.minecraft.entity.item.ItemFrameEntity", location, 1.5);
  383. step = list.getSize(sell_frame_locs) / numberofteams;
  384. team = math.roundDown(index / step);
  385. direction = map.get(sell_frame_directions, team);
  386. item = getItem(getRandomIndex());
  387. entity.spawnItemFrame(location, direction, item);
  388. map.add(sales_map, key, item);
  389. time = math.random(30, 60);
  390. entity.setName(key, text.number(time));
  391. }
  392. }
  393. sgoto(20, "loop");
  394. @checkgame
  395. wait();
  396. if(event == "living_pre_hurt") {
  397. if(!isPlayer(living_entity)) {
  398. goto("checkgame");
  399. }
  400. player = living_entity;
  401. } elseif(event == "human_hurt") {
  402. if(!isPlayer(entity)) {
  403. goto("checkgame");
  404. }
  405. player = entity;
  406. }
  407. if(player.hasMinigameId(player, script_id)) {
  408. ignoreGoto(event);
  409. }
  410. goto("checkgame");
  411. @block_click
  412. if(block.hasTag(wall_signs_tag, block)) {
  413. if(block.getSign(block_loc, 0) == "Click here") {
  414. if(player.getItemAmount(player, false, emerald) >= 10) {
  415. direction = block.getState(block_loc, facing_prop);
  416. block.set(block_loc, air);
  417. item = getItem(getRandomIndex());
  418. entity.spawnItemFrame(block_loc, direction, item);
  419. entity = list.getIndex(humans_list, list.getIndexOf(sell_frame_locs, block_loc));
  420. map.add(sales_map, entity, item);
  421. time = math.random(30, 60);
  422. entity.setName(entity, text.number(time));
  423. player.removeItem(player, emerald10);
  424. } else {
  425. speakPrefix(player, gamename, "You need 10 emeralds.");
  426. }
  427. }
  428. }
  429. goto("checkgame");
  430. @living_pre_hurt
  431. if(isPlayer(living_entity)) {
  432. cancel = true;
  433. }
  434. goto("checkgame");
  435. @block_break
  436. @block_place
  437. cancel = true;
  438. goto("checkgame");
  439. @human_hurt
  440. if(isPlayer(entity)) {
  441. player = entity;
  442. if(map.contains(sales_map, human)) {
  443. hand_item = entity.getEquip(player, "hand");
  444. aim_item = map.get(sales_map, human);
  445. if(item.getType(hand_item) == item.getType(aim_item)) {
  446. player_uuid = player.getUuid(player);
  447. team = map.get(players, player_uuid);
  448. direction = map.get(sell_frame_directions, team);
  449. item = getItem(getRandomIndex());
  450. location = list.getIndex(sell_frame_locs, list.getIndexOf(humans_list, human));
  451. entity.removeAll("net.minecraft.entity.item.ItemFrameEntity", location, 1.5);
  452. entity.spawnItemFrame(location, direction, item);
  453. map.add(sales_map, human, item);
  454. time = math.random(30, 60);
  455. entity.setName(human, text.number(time));
  456. player.giveItem(player, emerald);
  457. player.removeItem(player, aim_item);
  458. map.add(points, team, map.get(points, team) + 1);
  459. updateDisplay();
  460. speakPrefix(player, gamename, "Thank you §e+§r1 §aSmaragd");
  461. } else {
  462. speakPrefix(player, gamename, "Wrong item in your mainhand.");
  463. }
  464. }
  465. } else {
  466. if(entity.getName(human) != "Recipes") {
  467. speakPrefix(player, gamename, "Shop not unlocked.");
  468. }
  469. }
  470. goto("checkgame");
  471. @inv_click
  472. if(inv_name == "Recipes") {
  473. player_uuid = player.getUuid(player);
  474. team = map.get(players, player_uuid);
  475. item_type = item.getType(item);
  476. if(item_type == air) {
  477. goto("checkgame");
  478. }
  479. if(item_type == paper) {
  480. name = item.getName(item);
  481. if(text.contains(name, "<<") || text.contains(name, ">>")) {
  482. page = removeFormat(name);
  483. page = text.replace(page, "<<", "");
  484. page = text.replace(page, ">>", "");
  485. page = read.number(page);
  486. if(inv_slot == 45) {
  487. setRecipePage(player, inv, page);
  488. }
  489. if(inv_slot == 46) {
  490. setRecipePage(player, inv, page);
  491. }
  492. goto("checkgame");
  493. }
  494. }
  495. index = getIndexFromItemType(item_type);
  496. if(index == null) {
  497. goto("checkgame");
  498. }
  499. setItemFrames(team, index);
  500. }
  501. goto("checkgame");
  502. @entity_click
  503. if(entity.getType(entity) == "human") {
  504. if(entity.getName(entity) == "Recipes") {
  505. player_uuid = player.getUuid(player);
  506. menu = map.get(recipe_menus, player_uuid);
  507. setRecipePage(player, menu, 1);
  508. inv.open(menu, player, "Recipes");
  509. }
  510. goto("checkgame");
  511. }
  512. human = entity;
  513. entity = player;
  514. goto("human_hurt");
  515. @player_post_respawn
  516. player_uuid = player.getUuid(player);
  517. team = map.get(players, player_uuid);
  518. location = map.get(spawn_locs, team);
  519. entity.teleport(player, location);
  520. goto("checkgame");
  521. @item_air_click
  522. if(hand == "MAIN_HAND") {
  523. item = entity.getEquip(player, "hand");
  524. } else {
  525. item = entity.getEquip(player, "offhand");
  526. }
  527. if(item.getType(item) == "minecraft:ender_pearl") {
  528. cancel = true;
  529. }
  530. goto("checkgame");
  531. @player_logout
  532. @player_giveup
  533. minigame.speakAll(gamename, concat("§8", player.getName(player), " §rhas left the game."));
  534. showstats(player, false);
  535. player_uuid = player.getUuid(player);
  536. //Building-Perms wieder geben
  537. if(list.contains(removed_perms, player_uuid)) {
  538. list.remove(removed_perms, player_uuid);
  539. perm.registerPlayer(player_uuid, 1);
  540. perm.registerPlayer(player_uuid, 15);
  541. }
  542. if(singleteam) {
  543. script = script.getFromId(script_id);
  544. minigame.kickPlayer(script, player);
  545. minigame.term(script, gamesignloc);
  546. term();
  547. }
  548. team = map.get(players, player_uuid);
  549. map.remove(players, player_uuid);
  550. script = script.getFromId(script_id);
  551. minigame.kickPlayer(script, player);
  552. amount = map.get(playersinteam, team) - 1;
  553. map.add(playersinteam, team, amount);
  554. if(amount <= 0) {
  555. list.remove(allteams, team);
  556. if(list.getSize(allteams) == 1) {
  557. winning_team = list.getIndex(allteams, 0);
  558. winner_list = map.get(teamidtolist, winning_team);
  559. goto("win");
  560. }
  561. }
  562. minigame.displayRemoveAll(2 + team);
  563. goto("checkgame");
  564. @win
  565. team_string = "";
  566. for(h = 0; h < list.getSize(winner_list); h++) {
  567. if(team_string == "") {
  568. team_string = player.getName(list.getIndex(winner_list, h));
  569. } else {
  570. team_string = concat(team_string, " ", player.getName(list.getIndex(winner_list, h)));
  571. }
  572. }
  573. if(!singleteam) {
  574. minigame.speakAll( gamename, concat("Team ", map.get(colorcodes, winning_team), "(", team_string, ") §rhas won."));
  575. }
  576. for(i = 0; i < list.getSize(player_list); i++) {
  577. player_uuid = list.getIndex(player_list, i);
  578. p = player.get(player_uuid);
  579. team = map.get(players, player_uuid);
  580. if(team == winning_team) {
  581. showstats(p, true);
  582. } else {
  583. showstats(p, false);
  584. }
  585. script = script.getFromId(script_id);
  586. minigame.kickPlayer(script, p);
  587. }
  588. //Building-Perms wieder geben
  589. for(i = 0; i < list.getSize(removed_perms); i++) {
  590. player_uuid = list.getIndex(removed_perms, i);
  591. perm.registerPlayer(player_uuid, 1);
  592. perm.registerPlayer(player_uuid, 15);
  593. }
  594. minigame.kickAllPlayers(script);
  595. minigame.term(script, gamesignloc);
  596. term();
  597. function showstats(player, won) { //Player player, Boolean won
  598. if($singleteam) {
  599. return;
  600. }
  601. player_id = player.getId(player);
  602. last_record = getPoints($rankingtable, player_id);
  603. if(won) {
  604. last_record++;
  605. }
  606. playedgames = getPlayedGames($rankingtable, player_id) + 1;
  607. setRanking($rankingtable, player_id, last_record, playedgames);
  608. minigame.statsHeader(player, $gamename, "§e");
  609. minigame.statsLine(player, "§e", "Won games", text.number(last_record));
  610. minigame.statsLine(player, "§e", "Played games", text.number(playedgames));
  611. if(playedgames != 0) {
  612. minigame.statsLine(player, "§e", "Win ratio", concat(text.number(math.roundComma((last_record / playedgames) * 100, 2)), "%"));
  613. }
  614. }
  615. function updateDisplay() {
  616. minigame.displayAll(0, $gamename);
  617. for(i = 0; i < list.getSize($allteams); i++) {
  618. team = list.getIndex($allteams, i);
  619. teamlist = map.get($teamidtolist, team);
  620. team_string = "";
  621. for(h = 0; h < list.getSize(teamlist); h++) {
  622. if(team_string == "") {
  623. team_string = player.getName(list.getIndex(teamlist, h));
  624. } else {
  625. team_string = concat(team_string, " ", player.getName(list.getIndex(teamlist, h)));
  626. }
  627. }
  628. minigame.displayAll(2 + team, concat("§r", text.number(map.get($points, team)), " ", map.get($colorcodes, team), team_string));
  629. }
  630. }
  631. function addItem(item, item1, item2, item3, item4, item5, item6, item7, item8, item9) {
  632. array = array.new(10);
  633. array[0] = item;
  634. array[1] = item1;
  635. array[2] = item2;
  636. array[3] = item3;
  637. array[4] = item4;
  638. array[5] = item5;
  639. array[6] = item6;
  640. array[7] = item7;
  641. array[8] = item8;
  642. array[9] = item9;
  643. list.add($items_list, array);
  644. }
  645. function getRandomIndex() {
  646. return math.random(0, list.getSize($items_list) - 1);
  647. }
  648. function getIndexFromItemType(item_type) {
  649. for(i = 0; i < list.getSize($items_list); i++) {
  650. array = list.getIndex($items_list, i);
  651. if(array[0] == item_type) {
  652. return i;
  653. }
  654. }
  655. return null;
  656. }
  657. function getItem(index) {
  658. array = list.getIndex($items_list, index);
  659. return read.item(array[0]);
  660. }
  661. function setItemFrames(team, index) {
  662. loc = list.getIndex($frame_locs, team);
  663. entity.removeAll("net.minecraft.entity.item.ItemFrameEntity", loc, 3.5);
  664. direction = map.get($frame_directions, team);
  665. array = list.getIndex($items_list, index);
  666. entity.spawnItemFrame(loc, direction, read.item(array[0]));
  667. if(direction == "north") {
  668. entity.spawnItemFrame(loc.mod(loc, 1, -1, 0), direction, read.item(array[1]));
  669. entity.spawnItemFrame(loc.mod(loc, 0, -1, 0), direction, read.item(array[2]));
  670. entity.spawnItemFrame(loc.mod(loc, -1, -1, 0), direction, read.item(array[3]));
  671. entity.spawnItemFrame(loc.mod(loc, 1, -2, 0), direction, read.item(array[4]));
  672. entity.spawnItemFrame(loc.mod(loc, 0, -2, 0), direction, read.item(array[5]));
  673. entity.spawnItemFrame(loc.mod(loc, -1, -2, 0), direction, read.item(array[6]));
  674. entity.spawnItemFrame(loc.mod(loc, 1, -3, 0), direction, read.item(array[7]));
  675. entity.spawnItemFrame(loc.mod(loc, 0, -3, 0), direction, read.item(array[8]));
  676. entity.spawnItemFrame(loc.mod(loc, -1, -3, 0), direction, read.item(array[9]));
  677. } elseif(direction == "east") {
  678. entity.spawnItemFrame(loc.mod(loc, 0, -1, -1), direction, read.item(array[1]));
  679. entity.spawnItemFrame(loc.mod(loc, 0, -1, 0), direction, read.item(array[2]));
  680. entity.spawnItemFrame(loc.mod(loc, 0, -1, 1), direction, read.item(array[3]));
  681. entity.spawnItemFrame(loc.mod(loc, 0, -2, -1), direction, read.item(array[4]));
  682. entity.spawnItemFrame(loc.mod(loc, 0, -2, 0), direction, read.item(array[5]));
  683. entity.spawnItemFrame(loc.mod(loc, 0, -2, 1), direction, read.item(array[6]));
  684. entity.spawnItemFrame(loc.mod(loc, 0, -3, -1), direction, read.item(array[7]));
  685. entity.spawnItemFrame(loc.mod(loc, 0, -3, 0), direction, read.item(array[8]));
  686. entity.spawnItemFrame(loc.mod(loc, 0, -3, 1), direction, read.item(array[9]));
  687. } elseif(direction == "south") {
  688. entity.spawnItemFrame(loc.mod(loc, -1, -1, 0), direction, read.item(array[1]));
  689. entity.spawnItemFrame(loc.mod(loc, 0, -1, 0), direction, read.item(array[2]));
  690. entity.spawnItemFrame(loc.mod(loc, 1, -1, 0), direction, read.item(array[3]));
  691. entity.spawnItemFrame(loc.mod(loc, -1, -2, 0), direction, read.item(array[4]));
  692. entity.spawnItemFrame(loc.mod(loc, 0, -2, 0), direction, read.item(array[5]));
  693. entity.spawnItemFrame(loc.mod(loc, 1, -2, 0), direction, read.item(array[6]));
  694. entity.spawnItemFrame(loc.mod(loc, -1, -3, 0), direction, read.item(array[7]));
  695. entity.spawnItemFrame(loc.mod(loc, 0, -3, 0), direction, read.item(array[8]));
  696. entity.spawnItemFrame(loc.mod(loc, 1, -3, 0), direction, read.item(array[9]));
  697. } elseif(direction == "west") {
  698. entity.spawnItemFrame(loc.mod(loc, 0, -1, 1), direction, read.item(array[1]));
  699. entity.spawnItemFrame(loc.mod(loc, 0, -1, 0), direction, read.item(array[2]));
  700. entity.spawnItemFrame(loc.mod(loc, 0, -1, -1), direction, read.item(array[3]));
  701. entity.spawnItemFrame(loc.mod(loc, 0, -2, 1), direction, read.item(array[4]));
  702. entity.spawnItemFrame(loc.mod(loc, 0, -2, 0), direction, read.item(array[5]));
  703. entity.spawnItemFrame(loc.mod(loc, 0, -2, -1), direction, read.item(array[6]));
  704. entity.spawnItemFrame(loc.mod(loc, 0, -3, 1), direction, read.item(array[7]));
  705. entity.spawnItemFrame(loc.mod(loc, 0, -3, 0), direction, read.item(array[8]));
  706. entity.spawnItemFrame(loc.mod(loc, 0, -3, -1), direction, read.item(array[9]));
  707. }
  708. }
  709. function resetSigns() {
  710. step = list.getSize($sell_frame_locs) / $numberofteams;
  711. team = 0;
  712. counter = 0;
  713. for(i = 0; i < list.getSize($sell_frame_locs); i++) {
  714. if(counter != 0) { //Erste Locs werden übersprungen. Kein Schild platzieren = Freigeschalteter Shop
  715. loc = list.getIndex($sell_frame_locs, i);
  716. entity.removeAll("net.minecraft.entity.item.ItemFrameEntity", loc, 1.5);
  717. direction = map.get($sell_frame_directions, team);
  718. block.set(loc, concat("minecraft:oak_wall_sign[facing=", direction, "]"));
  719. block.setSign(loc, 0, "Click here");
  720. block.setSign(loc, 1, "to unlock for");
  721. block.setSign(loc, 2, "§a10 §rEmerald");
  722. block.setSign(loc, 3, ">> >> >>");
  723. }
  724. if(++counter == step) {
  725. counter = 0;
  726. team++;
  727. }
  728. }
  729. }
  730. function resetFrames() {
  731. for(i = 0; i < list.getSize($frame_locs); i++) {
  732. loc = list.getIndex($frame_locs, i);
  733. entity.removeAll("net.minecraft.entity.item.ItemFrameEntity", loc, 3.5);
  734. direction = map.get($frame_directions, i);
  735. entity.spawnItemFrame(loc, direction, $air_item);
  736. entity.spawnItemFrame(loc.mod(loc, 0, -1, 0), direction, $air_item);
  737. entity.spawnItemFrame(loc.mod(loc, 0, -2, 0), direction, $air_item);
  738. entity.spawnItemFrame(loc.mod(loc, 0, -3, 0), direction, $air_item);
  739. if(direction == "north" || direction == "south") {
  740. entity.spawnItemFrame(loc.mod(loc, 1, -1, 0), direction, $air_item);
  741. entity.spawnItemFrame(loc.mod(loc, -1, -1, 0), direction, $air_item);
  742. entity.spawnItemFrame(loc.mod(loc, 1, -2, 0), direction, $air_item);
  743. entity.spawnItemFrame(loc.mod(loc, -1, -2, 0), direction, $air_item);
  744. entity.spawnItemFrame(loc.mod(loc, 1, -3, 0), direction, $air_item);
  745. entity.spawnItemFrame(loc.mod(loc, -1, -3, 0), direction, $air_item);
  746. }
  747. if(direction == "east" || direction == "west") {
  748. entity.spawnItemFrame(loc.mod(loc, 0, -1, 1), direction, $air_item);
  749. entity.spawnItemFrame(loc.mod(loc, 0, -1, -1), direction, $air_item);
  750. entity.spawnItemFrame(loc.mod(loc, 0, -2, 1), direction, $air_item);
  751. entity.spawnItemFrame(loc.mod(loc, 0, -2, -1), direction, $air_item);
  752. entity.spawnItemFrame(loc.mod(loc, 0, -3, 1), direction, $air_item);
  753. entity.spawnItemFrame(loc.mod(loc, 0, -3, -1), direction, $air_item);
  754. }
  755. }
  756. }
  757. function resetContainers() {
  758. //1.Kiste
  759. for(i = 0; i < list.getSize($chest_locs1); i++) {
  760. loc = list.getIndex($chest_locs1, i);
  761. block.clone(loc.mod(loc, 0, -3, 0), loc);
  762. }
  763. //2.Kiste
  764. for(i = 0; i < list.getSize($chest_locs2); i++) {
  765. loc = list.getIndex($chest_locs2, i);
  766. block.clone(loc.mod(loc, 0, -3, 0), loc);
  767. }
  768. //Ofen
  769. for(i = 0; i < list.getSize($furnace_locs); i++) {
  770. loc = list.getIndex($furnace_locs, i);
  771. block.clone(loc.mod(loc, 0, -3, 0), loc);
  772. }
  773. }
  774. function setRecipePage(player, menu, page) {
  775. size = list.getSize($items_list);
  776. max_page = math.roundUp(size / 45);
  777. if(page > max_page) {
  778. return;
  779. }
  780. if(page > 1) {
  781. inv.setItem(menu, 45, read.item("minecraft:paper", 1, concat("§e", text.number(page - 1), " <<")));
  782. } else {
  783. inv.setItem(menu, 45, $air_item);
  784. }
  785. if(page < max_page) {
  786. inv.setItem(menu, 46, read.item("minecraft:paper", 1, concat("§e>> ", text.number(page + 1))));
  787. } else {
  788. inv.setItem(menu, 46, $air_item);
  789. }
  790. max_index = size - 1;
  791. for(i = 0; i < 45; i++) {
  792. list_index = i + 45 * (page - 1);
  793. if(list_index > max_index) {
  794. inv.setItem(menu, i, $air_item);
  795. } else {
  796. array = list.getIndex($items_list, list_index);
  797. inv.setItem(menu, i, read.item(array[0]));
  798. }
  799. }
  800. inv.update(player);
  801. }
  802. function getAllEntites() {
  803. humans_list = list.new();
  804. for(i = 0; i < list.getSize($humans_locs); i++) {
  805. location = list.getIndex($humans_locs, i);
  806. entity = entity.get(location, 10, "me.km.entities.EntityHuman");
  807. list.add(humans_list, entity);
  808. entity.setName(entity, "Shop");
  809. }
  810. return humans_list;
  811. }