survival.txt 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. event.load("entity_click");
  2. //event.load("inv_click");
  3. event.load("snuvi_click");
  4. event.load("player_pre_respawn");
  5. event.load("player_post_respawn");
  6. event.load("living_death");
  7. //event.load("player_join");
  8. event.load("player_move");
  9. event.load("block_click");
  10. event.load("entity_damage");
  11. event.load("explosion");
  12. event.load("entity_change_block");
  13. clan.loadData();
  14. tp_list = list.new();
  15. tp_map = map.new();
  16. tp_set = set.new();
  17. afk_loop_map = map.new();
  18. survival_respawn = set.new();
  19. overworld = world.getOverWorld();
  20. moveid_gamesspawn = event.addMoveData(loc.new(overworld, 93, 61, -31), loc.new(overworld, 97, 65, -30), 5, -1);
  21. moveid_creaspawn = event.addMoveData(loc.new(overworld, 102, 60, -20), loc.new(overworld, 103, 64, -16), 5, -1);
  22. moveid_mobarena = event.addMoveData(loc.new(overworld, 81, 59, -28), loc.new(overworld, 82, 63, -24), 5, -1);
  23. config = getScriptVar("server_config");
  24. adventure_chest_loc = loc.new(overworld, 177, 74, 237);
  25. adventure_aim_loc = loc.new(overworld, 180, 70, 241);
  26. mobarena_spawn = loc.new(overworld, 1150.5, -5, 1087, 90, 0);
  27. prefix_money = "§2Money";
  28. death_loc_map = map.new();
  29. redstone_mat = material.get("redstone");
  30. ice_mat = material.get("ice");
  31. blue_ice_mat = material.get("blue_ice");
  32. packed_ice_mat = material.get("packed_ice");
  33. ench_flame = enchantment.get("flame");
  34. ench_unbreaking = enchantment.get("unbreaking");
  35. ench_sharpness = enchantment.get("sharpness");
  36. piston_sound = sound.get("BLOCK_PISTON_EXTEND");
  37. adv_tp_sound = sound.get("BLOCK_PORTAL_TRAVEL");
  38. sound_category_ambient = sound.getCategory("AMBIENT");
  39. sound_category_master = sound.getCategory("MASTER");
  40. sound_flute = sound.get("BLOCK_NOTE_BLOCK_FLUTE");
  41. sound_harp = sound.get("BLOCK_NOTE_BLOCK_HARP");
  42. sound_pling = sound.get("BLOCK_NOTE_BLOCK_PLING");
  43. sound_cat = sound.get("ENTITY_CAT_AMBIENT");
  44. sound_stray_cat = sound.get("ENTITY_CAT_STRAY_AMBIENT");
  45. sound_purreow = sound.get("ENTITY_CAT_PURREOW");
  46. sound_drink_milk = sound.get("ENTITY_WANDERING_TRADER_DRINK_MILK");
  47. sound_slime_place = sound.get("BLOCK_SLIME_BLOCK_PLACE");
  48. sound_eating = sound.get("ENTITY_GENERIC_EAT");
  49. music_chirp = sound.get("MUSIC_DISC_CHIRP");
  50. Sound_Pitch_List = list.new();
  51. for(a = -12; a <= 12; a++){
  52. list.add(Sound_Pitch_List, math.pow(2, -a / 12));
  53. }
  54. casino_inv = inv.new("022200200", text.new("Casino"));
  55. casino_inv_id = inv.getId(casino_inv);
  56. lore_list = list.new();
  57. list.add(lore_list, text.new("§dClick to lose or double"));
  58. list.add(lore_list, text.new("§dWinrate: 45%"));
  59. inv.setItem(casino_inv, 1, item.custom.create("COPPER_COIN", 1, "§fGamble 1 Snuvi", lore_list));
  60. inv.setItem(casino_inv, 2, item.custom.create("SILVER_COIN", 1, "§fGamble 64 Snuvis", lore_list));
  61. inv.setItem(casino_inv, 3, item.custom.create("GOLD_COIN", 1, "§fGamble 4096 Snuvis", lore_list));;
  62. lore_list = list.new();
  63. lottery_value = lottery.getValue();
  64. list.add(lore_list, text.new(string.concat("§dWin value: ", string.number(lottery_value))));
  65. list.add(lore_list, text.new("§dBuy a ticket for 10 snuvis."));
  66. list.add(lore_list, text.new("§dWinrate 1:500"));
  67. inv.setItem(casino_inv, 6, item.custom.create("COPPER_COIN", 1, "§fLottery", lore_list));;
  68. bankmenu = inv.new("222200000", text.new("Banker"));
  69. bankinvid = inv.getId(bankmenu);
  70. inv.setItem(bankmenu, 0, item.custom.create("COPPER_COIN", 1, "§f1 Snuvi", null));
  71. inv.setItem(bankmenu, 1, item.custom.create("SILVER_COIN", 1, "§f64 Snuvis", null));
  72. inv.setItem(bankmenu, 2, item.custom.create("GOLD_COIN", 1, "§f4096 Snuvis", null));
  73. inv.setItem(bankmenu, 3, item.create("NETHERITE_BLOCK", 1, "§fAll Snuvis", null));
  74. msg.string("dev", "§bSurvival §rloaded.");
  75. @wait
  76. wait();
  77. if(event == "player_move") {
  78. if(id == moveid_mobarena) {
  79. player.setBackPosLoc(player, world.getServerSpawn());
  80. player.teleport(player, mobarena_spawn, false);
  81. goto("wait");
  82. }
  83. if(id == moveid_gamesspawn) {
  84. player.setBackPosLoc(player, world.getServerSpawn());
  85. player.teleport(player, world.getGamesSpawn(), false);
  86. goto("wait");
  87. }
  88. if(id == moveid_creaspawn) {
  89. player.setBackPosLoc(player, world.getServerSpawn());
  90. player.teleport(player, world.getCreativeSpawn(), false);
  91. goto("wait");
  92. }
  93. goto("wait");
  94. }
  95. //Wenn Event aus Survival-Welten, dann wird er verarbeitet
  96. if(event == "living_death") {
  97. loc = entity.getLocation(living_entity);
  98. } elseif(event == "explosion" || event == "entity_damage" || event == "entity_change_block") {
  99. loc = entity.getLocation(entity);
  100. } else {
  101. loc = entity.getLocation(player);
  102. }
  103. world_name = world.getName(loc.getWorld(loc));
  104. if(world.isSurvName(world_name)) {
  105. ignoreGoto(event);
  106. }
  107. goto("wait");
  108. @living_death
  109. if(isPlayer(living_entity)) {
  110. player = living_entity;
  111. setDeathLoc(player);
  112. }
  113. goto("wait");
  114. @entity_change_block
  115. if(entity.getType(entity) == "enderman") {
  116. cancel = true;
  117. }
  118. goto("wait");
  119. @explosion
  120. plot_list = plot.get(loc);
  121. plot_amount = list.getSize(plot_list);
  122. for(i = 0; i < plot_amount; i++) {
  123. plot = list.getIndex(plot_list, i);
  124. if(plot.isExplosive(plot)) {
  125. cancel = false;
  126. } else {
  127. cancel = true;
  128. break;
  129. }
  130. }
  131. //Kein Grundstück existiert
  132. if(plot_amount == 0) {
  133. cancel = false;
  134. }
  135. goto("wait");
  136. @entity_damage
  137. if(!isPlayer(entity)) {
  138. damager = player.getFromDamageSource(damage_source);
  139. if(!isPlayer(damager)) {
  140. goto("wait");
  141. }
  142. pet_type = entity.getType(entity);
  143. if(pet_type == "wolf" || pet_type == "cat" || pet_type == "parrot" || pet_type == "horse") {
  144. if(pet.isTamed(entity)) {
  145. owner = pet.getOwner(entity);
  146. if(owner == damager) {
  147. if(player.getNoPetDamage(damager)) {
  148. cancel = true;
  149. }
  150. }
  151. }
  152. }
  153. goto("wait");
  154. }
  155. player = entity;
  156. damager = player.getFromDamageSource(damage_source);
  157. if(damager == null) {
  158. goto("wait");
  159. }
  160. if(player == damager) {
  161. goto("wait");
  162. }
  163. if(!hasPvpOn(damager)) {
  164. cancel = true;
  165. msg.prefix(damager, "§5PvP", "You have PvP disabled.");
  166. goto("wait");
  167. }
  168. if(!hasPvpOn(player)) {
  169. cancel = true;
  170. msg.prefix(damager, "§5PvP", string.concat(player.getName(player), " has PvP disabled."));
  171. goto("wait");
  172. }
  173. goto("wait");
  174. @entity_click
  175. if(slot.isOffHand(hand)) {
  176. goto("wait");
  177. }
  178. if(!entity.isHuman(entity)) {
  179. goto("wait");
  180. }
  181. human_name = human.getName(entity);
  182. if(human_name == "Casino") {
  183. inv.open(casino_inv, player);
  184. }
  185. if(human_name == "Banker") {
  186. inv.open(bankmenu, player);
  187. goto("wait");
  188. }
  189. if(human_name == "§cMarvin") {
  190. item = living.getHand(player);
  191. item_name = item.getName(item);
  192. if(item_name != null && string.text(item_name) == "§fBeer") {
  193. sound.spawnForPlayer(player, $sound_drink_milk, $sound_category_master, 1, 1);
  194. msg.prefix(player, "§cmarvinius", "Prost!");
  195. } else {
  196. msg.prefix(player, "§cmarvinius", "Ich mag Gösser.");
  197. }
  198. goto("wait");
  199. }
  200. if(human_name == "§4Kajetan") {
  201. item = living.getHand(player);
  202. item_type = item.getType(item);
  203. sound.spawnForPlayer(player, $sound_slime_place, $sound_category_master, 1, 1);
  204. if(item_type == redstone_mat) {
  205. rand_number = math.random(0, 3);
  206. if(rand_number == 0){
  207. temp_message = "WUSIWUSIWUSIWUSIWUSIWUSIWUSIWUSI";
  208. }
  209. if(rand_number == 1){
  210. temp_message = "Wusi!";
  211. }
  212. if(rand_number == 2){
  213. temp_message = "Wusi?";
  214. }
  215. if(rand_number == 3){
  216. temp_message = "Wusi.";
  217. }
  218. msg.prefix(player, "§4kajetanjohannes", temp_message);
  219. goto("wait");
  220. }
  221. if(item_type == ice_mat || item_type == blue_ice_mat || item_type == packed_ice_mat){
  222. msg.prefix(player, "§4kajetanjohannes", "§bDas sieht nach mir aus.");
  223. }else{
  224. msg.prefix(player, "§4kajetanjohannes", "wusi");
  225. }
  226. goto("wait");
  227. }
  228. if(human_name == "§bNico") {
  229. rand_number = math.random(0, 25);
  230. if(rand_number > 13){
  231. sound.spawnForPlayer(player, $sound_cat, $sound_category_master, 1, 1);
  232. msg.prefix(player, "§bImKillerKatze", "Miau");
  233. goto("wait");
  234. }
  235. if(rand_number < 12){
  236. sound.spawnForPlayer(player, $sound_stray_cat, $sound_category_master, 1, 1);
  237. msg.prefix(player, "§bImKillerKatze", "Miau!");
  238. goto("wait");
  239. } else {
  240. sound.spawnForPlayer(player, $sound_purreow, $sound_category_master, 1, 1);
  241. msg.prefix(player, "§bImKillerKatze", "Schnurrr!");
  242. goto("wait");
  243. }
  244. goto("wait");
  245. }
  246. if(human_name == "§cFabio") {
  247. msg.prefix(player, "§cwertibaldi", "Kann grad nicht, bin im Einsatz für den Katastrophenschutz.");
  248. goto("wait");
  249. }
  250. if(human_name == "§cLucas") {
  251. item = living.getHand(player);
  252. item_name = item.getName(item);
  253. if(item_name != null && string.text(item_name) == "§fBeer") {
  254. msg.prefix(player, "§cMentorMentos", "Folg mir auf Twitch! ");
  255. msg(player, string.getLinkText("Klick mich an :D","https://www.twitch.tv/Mentor_Mentos"));
  256. } else {
  257. msg.prefix(player, "§cMentorMentos", "Ich mag Kölsch.");
  258. }
  259. goto("wait");
  260. }
  261. if(human_name == "§9Jan") {
  262. if(player.isSneaking(player)){
  263. msg.prefix(player, "§9SirTerence7", "Very secretive yes yes.");
  264. goto("wait");
  265. }
  266. rand_number = math.random(0, 7);
  267. if(rand_number < 4){
  268. msg.prefix(player, "§9SirTerence7", "Mathe bla... bla... bla...");
  269. }
  270. if(rand_number == 4){
  271. msg.prefix(player, "§9SirTerence7", "Fraktale bla... bla... bla...");
  272. }
  273. if(rand_number == 5){
  274. msg.prefix(player, "§9SirTerence7", "Höhere Dimensionen bla... bla... bla...");
  275. }
  276. if(rand_number == 6){
  277. msg.prefix(player, "§9SirTerence7", "*redet mit Händen weiter*");
  278. }
  279. if(rand_number == 7){
  280. msg.prefix(player, "§9SirTerence7", "*wechselt voller Faszination zwischen scheinbar zusammenhangslosen Themen hin und her*");
  281. }
  282. rand_number = math.random(0, 500);
  283. if(rand_number <= 2){
  284. sound.spawnForPlayer(player, $music_chirp, $sound_category_master, 1, 1);
  285. } else {
  286. rand_pitch = math.random(4, list.getSize(Sound_Pitch_List) - 5);
  287. if(rand_number < 200){
  288. pitch1 = list.getIndex(Sound_Pitch_List, rand_pitch-4);
  289. pitch2 = list.getIndex(Sound_Pitch_List, rand_pitch);
  290. pitch3 = list.getIndex(Sound_Pitch_List, rand_pitch+3);
  291. } else {
  292. if(rand_number < 300){
  293. pitch1 = list.getIndex(Sound_Pitch_List, rand_pitch-4);
  294. pitch1_2 = list.getIndex(Sound_Pitch_List, rand_pitch-2);
  295. pitch2 = list.getIndex(Sound_Pitch_List, rand_pitch);
  296. pitch3_2 = list.getIndex(Sound_Pitch_List, rand_pitch+1);
  297. pitch3 = list.getIndex(Sound_Pitch_List, rand_pitch+3);
  298. sound.spawnForPlayer(player, $sound_harp, $sound_category_master, 0.5, pitch1_2);
  299. sound.spawnForPlayer(player, $sound_harp, $sound_category_master, 0.5, pitch3_2);
  300. sound.spawnForPlayer(player, $sound_flute, $sound_category_master, 0.75, pitch1_2);
  301. sound.spawnForPlayer(player, $sound_flute, $sound_category_master, 0.75, pitch3_2);
  302. } else {
  303. pitch1 = list.getIndex(Sound_Pitch_List, rand_pitch-3);
  304. pitch2 = list.getIndex(Sound_Pitch_List, rand_pitch);
  305. pitch3 = list.getIndex(Sound_Pitch_List, rand_pitch+4);
  306. }
  307. }
  308. sound.spawnForPlayer(player, $sound_harp, $sound_category_master, 0.8, pitch1);
  309. sound.spawnForPlayer(player, $sound_harp, $sound_category_master, 0.9, pitch2);
  310. sound.spawnForPlayer(player, $sound_harp, $sound_category_master, 0.8, pitch2);
  311. sound.spawnForPlayer(player, $sound_flute, $sound_category_master, 0.9, pitch1);
  312. sound.spawnForPlayer(player, $sound_flute, $sound_category_master, 1, pitch2);
  313. sound.spawnForPlayer(player, $sound_flute, $sound_category_master, 0.9, pitch3);
  314. }
  315. goto("wait");
  316. }
  317. if(human_name == "§9Mareen") {
  318. rand_number = math.random(0, 5);
  319. if(rand_number > 1){
  320. msg.prefix(player, "§9Mareeeen", "Wo ist die Schokolade versteckt!?");
  321. }else{
  322. msg.prefix(player, "§9Mareeeen", "Ich esse deine Schokolade!");
  323. sound.spawnForPlayer(player, $sound_eating, $sound_category_master, 1, 1);
  324. }
  325. goto("wait");
  326. }
  327. goto("wait");
  328. if(entity_name == "Info-Point") {
  329. msg(player, string.getSpacer());
  330. msg(player, string.getClickText("§r [§cclick§r] [§eSurvival§r]", "/infopoint1"));
  331. msg(player, string.getClickText("§r [§cclick§r] [§eAdventure§r]", "/infopoint2"));
  332. msg(player, string.getClickText("§r [§cclick§r] [§ePlots§r]", "/infopoint3"));
  333. msg(player, string.getClickText("§r [§cclick§r] [§eClans§r]", "/infopoint4"));
  334. msg(player, string.getClickText("§r [§cclick§r] [§eCities§r]", "/infopoint5"));
  335. msg(player, string.getClickText("§r [§cclick§r] [§eShops§r]", "/infopoint6"));
  336. msg(player, string.getClickText("§r [§cclick§r] [§eMinigames§r]", "/infopoint7"), " ", string.getClickText("§f[§bTeleport§f]", "/games"));
  337. msg(player, string.getClickText("§r [§cclick§r] [§eQuests§r]", "/infopoint8"));
  338. msg(player, string.getClickText("§r [§cclick§r] [§eCreative§r]", "/infopoint12"), " ", string.getClickText("§f[§bTeleport§f]", "/creative"));
  339. msg(player, string.getClickText("§r [§cclick§r] [§eRanking§r]", "/infopoint9"), " ", string.getLinkText("§f[§bRanks§f]", "https://minecraft.hammerle.me/?site=ranks"));
  340. msg(player, string.getClickText("§r [§cclick§r] [§eRules§r]", "/infopoint10"), " ", string.getLinkText("§f[§bFake Rules§f]", "https://minecraft.hammerle.me/?site=rules"));
  341. msg(player, string.getClickText("§r [§cclick§r] [§eNote§r]", "/infopoint11"));
  342. goto("wait");
  343. }
  344. if(entity_name == "Adventure") {
  345. if(!player.isOnAdventure(player)) {
  346. msg.prefix(player, "§5Adventure", "You aren't on an adventure. Click the chest in the teleporter to start an adventure.");
  347. goto("wait");
  348. }
  349. player.setAdventure(player, false);
  350. adventures = player.getAdventureAmounts(player);
  351. if(adventures == null) {
  352. adventures = 0;
  353. }
  354. player.setAdventureAmounts(player, ++adventures);
  355. msg.prefix(player, "§5Adventure", "Congratulations, you finished your adventure, here ist your reward!");
  356. if(adventures == 10) {
  357. offerRank(player, "rank.pioneer");
  358. } elseif(adventures == 5) {
  359. offerRank(player, "rank.explorer");
  360. } elseif(adventures == 1) {
  361. offerRank(player, "rank.adventurer");
  362. }
  363. removeAdventureDisplay(player);
  364. player.safeGiveItem(player, item.getAmber());
  365. money.addBoost(player, 4096);
  366. goto("wait");
  367. }
  368. goto("wait");
  369. @player_join
  370. if(player.isOnAdventure(player)) {
  371. addAdventureDisplay(player, adventure_aim_loc);
  372. }
  373. goto("wait");
  374. @inv_click
  375. //Verhindert während eines (Abenteuer-)Teleports, die Benutzung des Spielerinventars (inkl. Crafting-Bereich!)
  376. player_uuid = player.getUuid(player);
  377. if(set.contains(tp_set, player_uuid)) {
  378. cancel = true;
  379. }
  380. goto("wait");
  381. @snuvi_click
  382. inv_id = inv.getId(inv);
  383. if(inv_id == bankinvid) { //Bankmenü
  384. //Einzahlen
  385. if(click == "RIGHT" || click == "SHIFT_RIGHT") {
  386. amount_items = 1;
  387. if(click == "SHIFT_RIGHT") {
  388. amount_items = 64;
  389. }
  390. player_inv = player.getInv(player);
  391. gold_item = item.custom.create("GOLD_COIN", 1, null, null);
  392. silver_item = item.custom.create("SILVER_COIN", 1, null, null);
  393. copper_item = item.custom.create("COPPER_COIN", 1, null, null);
  394. gold_inv = inv.getItemAmount(player_inv, gold_item);
  395. silver_inv = inv.getItemAmount(player_inv, silver_item);
  396. copper_inv = inv.getItemAmount(player_inv, copper_item);
  397. if(inv_slot == 0) {
  398. depositSnuvis(player, amount_items, 0, 0);
  399. }
  400. elseif(inv_slot == 1) {
  401. depositSnuvis(player, 0, amount_items, 0);
  402. }
  403. elseif(inv_slot == 2) {
  404. depositSnuvis(player, 0, 0, amount_items);
  405. }
  406. elseif(inv_slot == 3) {
  407. gold_inv = inv.getItemAmount(player_inv, item.custom.create("GOLD_COIN", 1, null, null));
  408. silver_inv = inv.getItemAmount(player_inv, item.custom.create("SILVER_COIN", 1, null, null));
  409. copper_inv = inv.getItemAmount(player_inv, item.custom.create("COPPER_COIN", 1, null, null));
  410. depositSnuvis(player, copper_inv, silver_inv, gold_inv);
  411. }
  412. goto("wait");
  413. }
  414. //Auszahlen
  415. if(click == "LEFT" || click == "SHIFT_LEFT") {
  416. amount_items = 1;
  417. if(click == "SHIFT_LEFT") {
  418. amount_items = 64;
  419. }
  420. if(inv_slot == 0) {
  421. withdrawSnuvis(player, amount_items, 0, 0);
  422. }
  423. elseif(inv_slot == 1) {
  424. withdrawSnuvis(player, 0, amount_items, 0);
  425. }
  426. elseif(inv_slot == 2) {
  427. withdrawSnuvis(player, 0, 0, amount_items);
  428. }
  429. elseif(inv_slot == 3) {
  430. a = money.split(getMoney(player));
  431. withdrawSnuvis(player, a[2], a[1], a[0]);
  432. }
  433. }
  434. goto("wait");
  435. }
  436. if(inv_id == casino_inv_id) {
  437. //Lottery
  438. if(inv_slot == 6) {
  439. ticket_price = 10;
  440. if(!hasEnoughMoney(player, ticket_price)) {
  441. msg.action(player, "Not enough snuvis on your account.");
  442. goto("wait");
  443. }
  444. money.sub(player, ticket_price);
  445. new_value = lottery.addValue(10);
  446. item = inv.getItem(inv, inv_slot);
  447. lore_list = item.getLore(item);
  448. list.setIndex(lore_list, 0, text.new(string.concat("§dWin value: ", string.number(new_value))));
  449. item.setLore(item, lore_list);
  450. win = math.random(1, 500);
  451. if(win == 1) {
  452. message = string.concat(player.getName(player), " won ", string.number(new_value), " snuvis.");
  453. msg.online("§dLottery", message);
  454. money.add(player, new_value);
  455. list.setIndex(lore_list, 0, text.new(string.concat("§dWin value: 0")));
  456. item.setLore(item, lore_list);
  457. lottery.setValue(0);
  458. }
  459. goto("wait");
  460. }
  461. //Gambler
  462. if(inv_slot == 1) {
  463. amount = 1;
  464. } elseif(inv_slot == 2) {
  465. amount = 64;
  466. } elseif(inv_slot == 3) {
  467. amount = 4096;
  468. }
  469. if(!hasEnoughMoney(player, amount)) {
  470. msg.action(player, "Not enough snuvis on your account.");
  471. goto("wait");
  472. }
  473. win = math.random(1, 100);
  474. if(win < 45) {
  475. money.add(player, amount);
  476. temp = " won ";
  477. } else {
  478. money.sub(player, amount);
  479. temp = " lost ";
  480. }
  481. if(amount == 4096) {
  482. message = string.concat(player.getName(player), temp, string.number(amount), " snuvis.");
  483. msg.radius("§dGambler", message, entity.getLocation(player), 10);
  484. }
  485. }
  486. goto("wait");
  487. function depositSnuvis(player, copper, silver, gold) {
  488. gold_item = item.custom.create("GOLD_COIN", 1, null, null);
  489. silver_item = item.custom.create("SILVER_COIN", 1, null, null);
  490. copper_item = item.custom.create("COPPER_COIN", 1, null, null);
  491. player_inv = player.getInv(player);
  492. gold_inv = inv.getItemAmount(player_inv, gold_item);
  493. silver_inv = inv.getItemAmount(player_inv, silver_item);
  494. copper_inv = inv.getItemAmount(player_inv, copper_item);
  495. if(copper > copper_inv || silver > silver_inv || gold > gold_inv) {
  496. player.action(player, text.new("Not enough coins in inventory."));
  497. return;
  498. }
  499. if(copper > 0) {
  500. item.setAmount(copper_item, copper);
  501. inv.removeItem(player_inv, copper_item);
  502. }
  503. if(silver > 0) {
  504. item.setAmount(silver_item, silver);
  505. inv.removeItem(player_inv, silver_item);
  506. }
  507. if(gold > 0) {
  508. item.setAmount(gold_item, gold);
  509. inv.removeItem(player_inv, gold_item);
  510. }
  511. sum = copper + silver * 64 + gold * 4096;
  512. money.add(player, sum);
  513. }
  514. function withdrawSnuvis(player, copper, silver, gold) {
  515. sum = copper + silver * 64 + gold * 4096;
  516. if(!hasEnoughMoney(player, sum)) {
  517. player.action(player, text.new("Not enough snuvis on your account."));
  518. return;
  519. }
  520. if(copper > 0) {
  521. copper_item = item.custom.create("COPPER_COIN", 1, null, null);
  522. item.setAmount(copper_item, copper);
  523. player.safeGiveItem(player, copper_item);
  524. }
  525. if(silver > 0) {
  526. silver_item = item.custom.create("SILVER_COIN", 1, null, null);
  527. item.setAmount(silver_item, silver);
  528. player.safeGiveItem(player, silver_item);
  529. }
  530. if(gold > 0) {
  531. gold_item = item.custom.create("GOLD_COIN", 1, null, null);
  532. item.setAmount(gold_item, gold);
  533. player.safeGiveItem(player, gold_item);
  534. }
  535. sum = copper + silver * 64 + gold * 4096;
  536. money.sub(player, sum);
  537. }
  538. function fire_ring(location, block_string, radius){
  539. loc_x = loc.getX(location);
  540. loc_y = loc.getY(location);
  541. loc_z = loc.getZ(location);
  542. for(a = -radius; a < radius + 1; a++){
  543. loc.setX(location, loc_x + a);
  544. for(b = -radius; b < radius + 1; b++){
  545. loc.setY(location, loc_y + b);
  546. for(c = -radius; c < radius + 1; c++){
  547. loc.setZ(location, loc_z + c);
  548. if(block.isAir(location)){
  549. block.set(location, block_string);
  550. }
  551. }
  552. }
  553. }
  554. }
  555. @block_click
  556. if(action == "RIGHT_CLICK_AIR") {
  557. player_loc = entity.getLocation(player);
  558. world = loc.getWorld(player_loc);
  559. if(!world.isOverworld(world.getName(world))) {
  560. goto("wait");
  561. }
  562. item = living.getHand(player);
  563. if(!item.isType(item, "CLOCK")) {
  564. goto("wait");
  565. }
  566. time = world.getTime(world);
  567. time_h = math.roundDown(time/1000) + 6;
  568. while(time_h >= 24) {
  569. time_h -= 24;
  570. }
  571. //m min = t ticks * 60m / 1000 ticks
  572. time_m = time%1000;
  573. time_m = math.roundDown(time_m * 60 / 1000);
  574. if(time_m < 10) {
  575. time_m = string.concat("0", string.number(time_m));
  576. } else {
  577. time_m = string.number(time_m);
  578. }
  579. msg.prefix(player, "§eClock", string.concat(string.number(time_h), ":", time_m));
  580. goto("wait");
  581. }
  582. if(action == "RIGHT_CLICK_BLOCK") {
  583. if(block.isType(block, "SPAWNER")) {
  584. if(!player.isCreative(player)) {
  585. cancel = true;
  586. goto("wait");
  587. }
  588. }
  589. }
  590. goto("wait");
  591. @player_pre_respawn
  592. if(loc.isInSurvWorld(entity.getLocation(player))) {
  593. set.add(survival_respawn, player.getUuid(player));
  594. }
  595. goto("wait");
  596. @player_post_respawn
  597. player_uuid = player.getUuid(player);
  598. if(set.contains(survival_respawn, player_uuid)) {
  599. set.remove(survival_respawn, player_uuid);
  600. if(player.isOnAdventure(player)) {
  601. tp_loc = player.getAdventureStart(player);
  602. entity.teleport(player, tp_loc);
  603. goto("wait");
  604. }
  605. /*amount = skill.getAmount(player, "skill.comeback");
  606. if(skill.isActivated(player, "skill.comeback") && amount > 0) {
  607. new_amount = amount - 1;
  608. skill.setAmount(player, "skill.comeback", new_amount);
  609. msg.prefix(player, prefix_skill, concat("Used Comeback. New amount: ", string.number(new_amount)));
  610. entity.teleport(player, getDeathLoc(player));
  611. goto("wait");
  612. }*/
  613. //entity.teleport(player, world.getServerSpawn());
  614. }
  615. goto("wait");
  616. function lottery.set(location, amount) {
  617. location = loc.mod(location, 0.5, 0, 0.5);
  618. list = living.near(location, 0.1);
  619. text_entity = list.getIndex(list, 0);
  620. name = entity.getName(text_entity);
  621. if(!text.startsWith(name, "Snuvis to win: ", 0)) {
  622. snuvi.debug("Lottery error");
  623. return;
  624. }
  625. entity.setName(text_entity, string.concat("Snuvis to win: ", string.number(amount)), true);
  626. }
  627. function lottery.add(location, amount) {
  628. location = loc.mod(location, 0.5, 0, 0.5);
  629. list = living.near(location, 0.1);
  630. text_entity = list.getIndex(list, 0);
  631. name = entity.getName(text_entity);
  632. if(!text.startsWith(name, "Snuvis to win:", 0)) {
  633. snuvi.debug("Lottery error");
  634. return null;
  635. }
  636. amount = text.convert(text.subString(name, 15, text.length(name))) + 1;
  637. entity.setName(text_entity, string.concat("Snuvis to win: ", string.number(amount)), true);
  638. return amount;
  639. }
  640. function setDeathLoc(player) {
  641. map.add($death_loc_map, player.getUuid(player), entity.getLocation(player));
  642. }
  643. function getDeathLoc(player) {
  644. return map.getOrDefault($death_loc_map, player.getUuid(player), world.getServerSpawn());
  645. }
  646. function lottery.addValue(value) {
  647. config = getServerConfig();
  648. new_value = config.getDouble(config, "lottery_value", 0) + value;
  649. config.set(config, "lottery_value", new_value);
  650. config.saveAsync(config);
  651. return new_value;
  652. }
  653. function lottery.setValue(value) {
  654. config = getServerConfig();
  655. config.set(config, "lottery_value", value);
  656. config.saveAsync(config);
  657. }
  658. function lottery.getValue() {
  659. config = getServerConfig();
  660. return config.getDouble(config, "lottery_value", 0);
  661. }