event.load("player_join"); event.load("player_is_attacked"); event.load("player_hurt"); event.load("block_click"); event.load("player_logout"); event.load("player_giveup"); event.load("custom_command"); gamesspawnloc = read.location(ggv("SERVER", "gamesspawn")); airitem = read.item("minecraft:air"); barrier = read.item("minecraft:barrier"); gamename = "§dPvP"; gosub("setstart"); list.new(all); list.new(roundplayers); map.new(wincounter); player = script.getLeader(); player_name = player.getName(player); gosub("lobbycore"); goto("simplelobby"); @lobby player.speak(player, gamename, "Gewinne ", text.number(roundsforwin), " Runden, um das Spiel zu gewinnen"); return; @leavelobby return; @leavegame list.remove(roundplayers, player); if(player.isSpectator(player)) { player.setGamemode(player, "survival"); } kickplayer(player); size = list.getSize(all); if(size < 2) { goto("wincore"); } return; @finalstart block.setSign(gamesignloc, 3, "§6Läuft"); list.remove(starttimes, 20); list.remove(starttimes, 15); list.remove(starttimes, 10); for(i = 0; i <= list.getSize(all) - 1; i++) { player = list.getIndex(all, i); map.add(wincounter, player, 0); if(player.isSurvival(player)) { if(player.isAdventure(player)) { player.setGamemode(player, "survival"); } } else { player.setGamemode(player, "survival"); } if(player.hasFly(player)) { command("fly ", player_name, " off"); } } @newround entity.removeAll("net.minecraft.entity.item.EntityItem", middleloc, radius); displaypoints(); list.clear(roundplayers); size = list.getSize(all); for(i = 0; i <= size - 1; i++) { player = list.getIndex(all, i); spawnloc = list.getIndex(spawnlocs, i); setbarriers(spawnloc, true); entity.setHealth(player, 20); player.setHunger(player, 20); player.setSaturation(player, 5); counterindex = 0; player.clearInventory(player); list.add(roundplayers, player); if(player.isSpectator(player)) { player.setGamemode(player, "survival"); } entity.teleport(player, spawnloc); } @startcountdown size = list.getSize(all); noticetime = list.getIndex(starttimes, counterindex); if(noticetime == 5) { for(i = 0; i <= size - 1; i++) { entity.removeAll("net.minecraft.entity.item.EntityItem", middleloc, radius); p = list.getIndex(all, i); giveitems(p); title.send(p, gamename); } } if(noticetime == 0) { displaypoints(); for(i = 0; i <= list.getSize(all) - 1; i++) { spawnloc = list.getIndex(spawnlocs, i); setbarriers(spawnloc, false); } goto("checkgame"); } noticetime2 = list.getIndex(starttimes, ++counterindex); if(noticetime == 1) { player.speak("all", gamename, concat("§rDie Runde startet in §b", text.number(noticetime), " §rSekunde")); } else { player.speak("all", gamename, concat("§rDie Runde startet in §b", text.number(noticetime), " §rSekunden")); } stime = (noticetime - noticetime2) * 20; sgoto(stime, "startcountdown"); for(i = 0; i <= size - 1; i++) { p = list.getIndex(all, i); player.playSound(p, "block.note.bass"); } @checkstart wait(); if(event == "player_is_attacked" || event == "block_click") { cancel = true; } elseif(event == "player_logout" || event == "player_giveup") { gosub("leavegame"); } goto("checkstart"); @checkgame wait(); if(event == "block_click") { cancel = true; } elseif(event == "player_logout" || event == "player_giveup") { gosub("leavegame"); } elseif(event == "player_is_attacked") { if(player_involved) { if(player == sec_player) { cancel = true; goto("checkgame"); } } } elseif(event == "player_hurt") { msg("dev", entity.getHealth(player)); msg("dev", damage); if(player_killed) { list.remove(roundplayers, player); if(list.getSize(roundplayers) < 2) { goto("wincore"); } player.setGamemode(player, "spectator"); entity.teleport(player, middleloc); } } goto("checkgame"); @wincore winner = list.getIndex(roundplayers, 0); winner_name = player.getName(winner); wonrounds = map.get(wincounter, winner) + 1; map.add(wincounter, winner, wonrounds); size = list.getSize(all); if(size > 1) { if(wonrounds < roundsforwin) { goto("newround"); } } player.speak("all", gamename, winner_name, " hat das Spiel gewonnen"); for(i = 0; i <= size - 1; i++) { player = list.getIndex(all, i); entity.teleport(player, gamesspawnloc); resetplayer(player); } entity.removeAll("net.minecraft.entity.item.EntityItem", middleloc, radius); block.setSign(gamesignloc, 2, concat("0/", text.number(maxplayers))); block.setSign(gamesignloc, 3, "§2Wartet"); term(); function setbarriers(location, boolean) { if(boolean) { block.set(loc.mod(location, 1, 1, 0), $barrier); block.set(loc.mod(location, -1, 1, 0), $barrier); block.set(loc.mod(location, 0, 1, 1), $barrier); block.set(loc.mod(location, 0, 1, -1), $barrier); block.set(loc.mod(location, 0, 2, 0), $barrier); } else { block.set(loc.mod(location, 1, 1, 0), $airitem); block.set(loc.mod(location, -1, 1, 0), $airitem); block.set(loc.mod(location, 0, 1, 1), $airitem); block.set(loc.mod(location, 0, 1, -1), $airitem); block.set(loc.mod(location, 0, 2, 0), $airitem); } return; } function displaypoints() { display.reset("all"); display.add("all", 1, "§6Gewonnene Runden"); for(i = 0; i <= list.getSize($all) - 1; i++) { p = list.getIndex($all, i); display.add("all", i + 2, concat(text.number(map.get($wincounter, p)), " ", player.getName(p))); } return; } function giveitems(player) { for(i = 0; i <= list.getSize($items) - 1; i++) { player.giveItem(player, list.getIndex($items, i)); } for(i = 0; i <= table.getSize($equip) - 1; i++) { entity.setEquip(player, table.get($equip, i, 0), table.get($equip, i, 1)); } return; }