pvp.txt 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. event.load("player_join");
  2. event.load("player_is_attacked");
  3. event.load("player_hurt");
  4. event.load("block_click");
  5. event.load("player_logout");
  6. event.load("player_giveup");
  7. event.load("custom_command");
  8. gamesspawnloc = read.location(ggv("SERVER", "gamesspawn"));
  9. airitem = read.item("minecraft:air");
  10. barrier = read.item("minecraft:barrier");
  11. gamename = "§dPvP";
  12. gosub("setstart");
  13. list.new(all);
  14. list.new(roundplayers);
  15. map.new(wincounter);
  16. player = script.getLeader();
  17. player_name = player.getName(player);
  18. gosub("lobbycore");
  19. goto("simplelobby");
  20. @lobby
  21. player.speak(player, gamename, "Gewinne ", text.number(roundsforwin), " Runden, um das Spiel zu gewinnen");
  22. return;
  23. @leavelobby
  24. return;
  25. @leavegame
  26. list.remove(roundplayers, player);
  27. if(player.isSpectator(player)) {
  28. player.setGamemode(player, "survival");
  29. }
  30. kickplayer(player);
  31. size = list.getSize(all);
  32. if(size < 2) {
  33. goto("wincore");
  34. }
  35. return;
  36. @finalstart
  37. block.setSign(gamesignloc, 3, "§6Läuft");
  38. list.remove(starttimes, 20);
  39. list.remove(starttimes, 15);
  40. list.remove(starttimes, 10);
  41. for(i = 0; i <= list.getSize(all) - 1; i++) {
  42. player = list.getIndex(all, i);
  43. map.add(wincounter, player, 0);
  44. if(player.isSurvival(player)) {
  45. if(player.isAdventure(player)) {
  46. player.setGamemode(player, "survival");
  47. }
  48. } else {
  49. player.setGamemode(player, "survival");
  50. }
  51. if(player.hasFly(player)) {
  52. command("fly ", player_name, " off");
  53. }
  54. }
  55. @newround
  56. entity.removeAll("net.minecraft.entity.item.EntityItem", middleloc, radius);
  57. displaypoints();
  58. list.clear(roundplayers);
  59. size = list.getSize(all);
  60. for(i = 0; i <= size - 1; i++) {
  61. player = list.getIndex(all, i);
  62. spawnloc = list.getIndex(spawnlocs, i);
  63. setbarriers(spawnloc, true);
  64. entity.setHealth(player, 20);
  65. player.setHunger(player, 20);
  66. player.setSaturation(player, 5);
  67. counterindex = 0;
  68. player.clearInventory(player);
  69. list.add(roundplayers, player);
  70. if(player.isSpectator(player)) {
  71. player.setGamemode(player, "survival");
  72. }
  73. entity.teleport(player, spawnloc);
  74. }
  75. @startcountdown
  76. size = list.getSize(all);
  77. noticetime = list.getIndex(starttimes, counterindex);
  78. if(noticetime == 5) {
  79. for(i = 0; i <= size - 1; i++) {
  80. entity.removeAll("net.minecraft.entity.item.EntityItem", middleloc, radius);
  81. p = list.getIndex(all, i);
  82. giveitems(p);
  83. title.send(p, gamename);
  84. }
  85. }
  86. if(noticetime == 0) {
  87. displaypoints();
  88. for(i = 0; i <= list.getSize(all) - 1; i++) {
  89. spawnloc = list.getIndex(spawnlocs, i);
  90. setbarriers(spawnloc, false);
  91. }
  92. goto("checkgame");
  93. }
  94. noticetime2 = list.getIndex(starttimes, ++counterindex);
  95. if(noticetime == 1) {
  96. player.speak("all", gamename, concat("§rDie Runde startet in §b", text.number(noticetime), " §rSekunde"));
  97. } else {
  98. player.speak("all", gamename, concat("§rDie Runde startet in §b", text.number(noticetime), " §rSekunden"));
  99. }
  100. stime = (noticetime - noticetime2) * 20;
  101. sgoto(stime, "startcountdown");
  102. for(i = 0; i <= size - 1; i++) {
  103. p = list.getIndex(all, i);
  104. player.playSound(p, "block.note.bass");
  105. }
  106. @checkstart
  107. wait();
  108. if(event == "player_is_attacked" || event == "block_click") {
  109. cancel = true;
  110. } elseif(event == "player_logout" || event == "player_giveup") {
  111. gosub("leavegame");
  112. }
  113. goto("checkstart");
  114. @checkgame
  115. wait();
  116. if(event == "block_click") {
  117. cancel = true;
  118. } elseif(event == "player_logout" || event == "player_giveup") {
  119. gosub("leavegame");
  120. } elseif(event == "player_is_attacked") {
  121. if(player_involved) {
  122. if(player == sec_player) {
  123. cancel = true;
  124. goto("checkgame");
  125. }
  126. }
  127. } elseif(event == "player_hurt") {
  128. msg("dev", entity.getHealth(player));
  129. msg("dev", damage);
  130. if(player_killed) {
  131. list.remove(roundplayers, player);
  132. if(list.getSize(roundplayers) < 2) {
  133. goto("wincore");
  134. }
  135. player.setGamemode(player, "spectator");
  136. entity.teleport(player, middleloc);
  137. }
  138. }
  139. goto("checkgame");
  140. @wincore
  141. winner = list.getIndex(roundplayers, 0);
  142. winner_name = player.getName(winner);
  143. wonrounds = map.get(wincounter, winner) + 1;
  144. map.add(wincounter, winner, wonrounds);
  145. size = list.getSize(all);
  146. if(size > 1) {
  147. if(wonrounds < roundsforwin) {
  148. goto("newround");
  149. }
  150. }
  151. player.speak("all", gamename, winner_name, " hat das Spiel gewonnen");
  152. for(i = 0; i <= size - 1; i++) {
  153. player = list.getIndex(all, i);
  154. entity.teleport(player, gamesspawnloc);
  155. resetplayer(player);
  156. }
  157. entity.removeAll("net.minecraft.entity.item.EntityItem", middleloc, radius);
  158. block.setSign(gamesignloc, 2, concat("0/", text.number(maxplayers)));
  159. block.setSign(gamesignloc, 3, "§2Wartet");
  160. term();
  161. function setbarriers(location, boolean) {
  162. if(boolean) {
  163. block.set(loc.mod(location, 1, 1, 0), $barrier);
  164. block.set(loc.mod(location, -1, 1, 0), $barrier);
  165. block.set(loc.mod(location, 0, 1, 1), $barrier);
  166. block.set(loc.mod(location, 0, 1, -1), $barrier);
  167. block.set(loc.mod(location, 0, 2, 0), $barrier);
  168. } else {
  169. block.set(loc.mod(location, 1, 1, 0), $airitem);
  170. block.set(loc.mod(location, -1, 1, 0), $airitem);
  171. block.set(loc.mod(location, 0, 1, 1), $airitem);
  172. block.set(loc.mod(location, 0, 1, -1), $airitem);
  173. block.set(loc.mod(location, 0, 2, 0), $airitem);
  174. }
  175. return;
  176. }
  177. function displaypoints() {
  178. display.reset("all");
  179. display.add("all", 1, "§6Gewonnene Runden");
  180. for(i = 0; i <= list.getSize($all) - 1; i++) {
  181. p = list.getIndex($all, i);
  182. display.add("all", i + 2, concat(text.number(map.get($wincounter, p)), " ", player.getName(p)));
  183. }
  184. return;
  185. }
  186. function giveitems(player) {
  187. for(i = 0; i <= list.getSize($items) - 1; i++) {
  188. player.giveItem(player, list.getIndex($items, i));
  189. }
  190. for(i = 0; i <= table.getSize($equip) - 1; i++) {
  191. entity.setEquip(player, table.get($equip, i, 0), table.get($equip, i, 1));
  192. }
  193. return;
  194. }