command /coinflip []: trigger: if arg 1 is not "open" or "bet" or "magazyn": send "&cPoprawne użycie: /coinflip " stop if arg 1 is "open": CoinFlipMenu(player) if arg 1 is "bet": BetCoinFlipMenu(player) if arg 1 is "magazyn": CoinFlipMagazyn(player, 1) function CoinFlipMagazyn(p: player, page: number): set {_gui} to chest inventory with 6 rows named "&8Magazyn &8(&bstr. %{_page}%&8)" loop {CoinFlipMagazyn::%{_p}%::*}: if loop-value is not air: add loop-value to {_acctualList::*} loop 45 times: set {_index} to ({_page} - 1) * 45 + loop-number if {_acctualList::%{_index}%} is not set: exit loop {_acctualList::%{_index}%} is not air set slot (loop-number - 1) of {_gui} to {_acctualList::%{_index}%} if {_acctualList::1} is not set: set slot 22 of {_gui} to barrier named "&cNie masz nic do odebrania!" if {_page} > 1: set slot 45 of {_gui} to arrow named "&7Wróć na stronę &6%{_page} - 1%" set {_nextPageIndex} to {_page} * 45 + 1 if {_acctualList::%{_nextPageIndex}%} is set: set slot 53 of {_gui} to arrow named "&7Przejdź na stronę &6%{_page} + 1%" set slot integers between 45 and 53 of {_gui} to gray stained glass pane named "&7" set slot 49 of {_gui} to lime wool named "&aOdbierz itemy z magazynu!" with lore " &7Po kliknięciu w ten slot " and "&7 dostaniesz do ekwipunku wszystkie" and "&7 itemy &awygrane &7z coin flip'a!" open {_gui} to {_p} function CoinFlipMenu(p: player): set {_x} to chest inventory with 6 rows named "&8Coinflip" set slot (integers between 0 and 8) and (integers between 45 and 53) of {_x} to gray stained glass pane named "&7" set {_n} to 8 if {CoinFlipList::*} is not set: set slot 21, 22, 23, 30, 31 and 32 of {_x} to barrier named "&cAby dodać coinflip wpisz komendę /coinflip bet" loop {CoinFlipList::*}: add 1 to {_n} set {_loopI} to loop-index set {_s::*} to split "%{_loopI}%" at "-" set {_now} to {_s::2} set {_seller} to {_s::1} if {_seller} = "%{_p}%": set {_message} to "&7Betujący: &aTy" set {_canDelete} to "&cKliknij prawym, aby usunąć bet'a!" else: set {_message} to "&7Betujący: &a%{_seller}%" set {_icon} to "%{CoinFlipListItems::%{_seller}%-%{_now}%::1}%" parsed as item set {_nowM} to {_now} replace all "object:" with "" in {_nowM} add "%{_message}%" and "&7Data założenia coinflip'a: &a%{_nowM}%" and "" and "&aKliknij, aby zobaczyć dostępne itemy!" to lore of {_icon} if {_canDelete} is set: add {_canDelete} to lore of {_icon} set slot {_n} of {_x} to {_icon} open {_x} to {_p} function CoinFlipItemReview(p: player, seller: text, now: text): if {_seller} = "Ty": set {_seller} to "%{_p}%" set {_x} to chest inventory with 5 rows named "Itemy: (&9%{_seller}% %{_now}%&8)" set {_n} to -1 set {_object} to "object:%{_now}%" loop {CoinFlipListItems::%{_seller}%-%{_object}%::*}: add 1 to {_n} if {_n} < 36: set slot {_n} of {_x} to "%loop-value%" parsed as item set slot (integers between 36 and 44) of {_x} to gray stained glass pane named "&7" set slot 36 of {_x} to red wool named "&cWróć" set slot 44 of {_x} to green wool named "&2Zacznij losowanie &8(&91/2&8)" open {_x} to {_p} function BetCoinFlipMenu(p: player): set {_x} to chest inventory with 5 rows named "&8Dodaj bet!" set slot (integers between 36 and 44) of {_x} to gray stained glass pane named "&7" set slot 44 of {_x} to lime wool named "&aZatwierdź bet!" open {_x} to {_p} function StartCoinFlip(p: offline player, seller: offline player, items: objects): set {_wait} to 1.3 tick set {_LoopIndex} to 0 add skull of {_p} named "&e%{_p}%" to {_drop::*} add skull of {_seller} named "&e%{_seller}%" to {_drop::*} set {_cf} to chest inventory with 3 rows named "&6Coinflip &7| &b%{_p}% - %{_seller}%" loop 32 times: add 1 to {_LoopIndex} if {_LoopIndex} is 1: set {_SlotX} to 8 loop 9 times: add 1 to {_SlotX} set {_re} to random element out of {_drop::*} set slot {_SlotX} of {_cf} to {_re} set {_TempSlot-%{_SlotX}%} to {_re} else: set {_SlotX} to 8 loop 9 times: add 1 to {_SlotX} if loop-value-2 is 4: set slot {_SlotX} of {_cf} to {_TempSlot-%{_SlotX}+1%} else: set slot {_SlotX} of {_cf} to {_TempSlot-%{_SlotX}+1%} set {_TempSlot-%{_SlotX}%} to {_TempSlot-%{_SlotX}+1%} set {_re} to random element out of {_drop::*} set slot 17 of {_cf} to {_re} set {_TempSlot-17} to {_re} set {_aX} to 0 set slot (integers between 0 and 8) and (integers between 18 and 26) of {_cf} to gray stained glass pane named "&7" set slot 4 and 22 of {_cf} to lime stained glass pane named "&7" open {_cf} to {_p} and {_seller} if {_LoopIndex} is 5: set {_wait} to 2 tick if {_LoopIndex} is 8: set {_wait} to 4 tick if {_LoopIndex} is 12: set {_wait} to 5 tick if {_LoopIndex} is 14: set {_wait} to 5.5 tick if {_LoopIndex} is 18: set {_wait} to 6 tick if {_LoopIndex} is 20: set {_wait} to 6.5 tick if {_LoopIndex} is 23: set {_wait} to 7 tick if {_LoopIndex} is 25: set {_wait} to 9 tick if {_LoopIndex} is 26: set {_wait} to 12 tick if {_LoopIndex} is 27: set {_wait} to 15 tick if {_LoopIndex} is 28: set {_wait} to 18 tick if {_LoopIndex} is 29: set {_wait} to 22 tick if {_LoopIndex} is 30: set {_wait} to 25 tick if {_LoopIndex} is 31: set {_wait} to 28 tick if {_LoopIndex} is 32: set {_wait} to 34 tick wait {_wait} set {_winner} to uncolored name of {_TempSlot-13} EndCoinflip("%{_p}%" parsed as player, "%{_seller}%" parsed as player, {_winner}, {_items::*}) function EndCoinflip(p: player, seller: player, winner: text, reward: objects): if {_p} = {_winner}: set {_winner} to {_p} set {_loser} to {_seller} else: set {_winner} to {_seller} set {_loser} to {_p} close {_loser}'s inventory close {_winner}'s inventory if "%{_loser}%" parsed as player is online: send title "&cNiestety przegrałeś swoje itemy!" to {_loser} else: set {OnJoinMessage::%{_loser}%::1} to "&cNiestety przegrałeś swoje itemy!" if "%{_winner}%" parsed as player is online: send title "&aWygrałeś coinflip!" with subtitle "&2Itemy które wygrałeś zostały przeniesione do magazynu! &8(&9/coinflip magazyn&8)!" to {_winner} else: set {OnJoinMessage::%{_loser}%::1} to "&aWygrałeś coinflip!" set {OnJoinMessage::%{_loser}%::2} to "&2Itemy które wygrałeś zostały przeniesione do magazynu! &8(&9/coinflip magazyn&8)!" add {_reward::*} to {CoinFlipMagazyn::%{_winner}%::*} add {_reward::*} to {CoinFlipMagazyn::%{_winner}%::*} on join: {OnJoinMessage::%player%::*} is set wait 5 seconds send title {OnJoinMessage::%player%::1} with subtitle {OnJoinMessage::%player%::2} to player clear {OnJoinMessage::%player%::*} on inventory click: if name of event-inventory is "&8Coinflip": cancel event if clicked slot is not air: clicked slot is not gray stained glass pane named "&7" clicked slot is not barrier named "&cAby dodać coinflip wpisz komendę /coinflip bet" set {_lore::*} to lore of clicked slot loop {_lore::*}: if loop-value contains "&7Betujący: ": set {_seller} to uncolored loop-value replace all "Betujący: " with "" in {_seller} else if loop-value contains "&7Data założenia coinflip'a: ": set {_now} to uncolored loop-value replace all "Data założenia coinflip'a: " with "" in {_now} clicked slot is not gray stained glass pane named "&7" clicked slot is not barrier named "&cAby dodać coinflip wpisz komendę /coinflip bet" if click type is right mouse button: if {_seller} = "Ty": set {_t} to true if clicked slot is air: set {_t} to true if {_t} is true: set {_seller} to player set {_object} to "object:%{_now}%" loop {CoinFlipListItems::%{_seller}%-%{_object}%::*}: if player have enough space for loop-value: give loop-value to player else: drop loop-value at location of player clear {CoinFlipListItems::%{_seller}%-%{_object}%::*} clear {CoinFlipList::%{_seller}%-%{_object}%} loop all players: if loop-player's current inventory's name is "&8Coinflip": CoinFlipMenu(loop-player) CoinFlipMenu(player) else: clicked slot is not air CoinFlipItemReview(player, {_seller}, {_now}) else: clicked slot is not air CoinFlipItemReview(player, {_seller}, {_now}) if name of event-inventory contains "&8Magazyn (": cancel event set {_split::*} to split uncolored name of event-inventory at "." replace all ")" and " " with "" in {_split::2} if clicked slot is 49: if slot 22 of event-inventory is not barrier named "&cNie masz nic do odebrania!": loop {CoinFlipMagazyn::%player%::*}: if player have enough space for loop-value: give loop-value to player clear {CoinFlipMagazyn::%player%::*} CoinFlipMagazyn(player, {_split::2} parsed as number) else: send "&cNie masz nic do odebrania!" if clicked slot is arrow: if clicked slot is 45: CoinFlipMagazyn(player, {_split::2} parsed as number - 1) if clicked slot is 53: CoinFlipMagazyn(player, {_split::2} parsed as number + 1) if name of event-inventory contains "&6Coinflip ": cancel event if name of event-inventory contains "Itemy: (": cancel event if clicked slot is 36: CoinFlipMenu(player) if clicked slot is 44: set {_split::*} to split uncolored name of event-inventory at " " replace all "Itemy: " and "(" and ")" with "" in {_split::*} set {_seller} to {_split::2} set {_now} to "%{_split::3}% %{_split::4}%" if {_seller} = "%player%": send "&cNie możesz dołączyć do swojego betu!" stop set {_itemki::*} to all items in event-inventory loop {_itemki::*}: if loop-value is not red wool named "&cWróć": if loop-value is not gray stained glass pane named "&7": if loop-value is not green wool named "&2Zacznij losowanie &8(&91/2&8)": add loop-value to {_acctualList::*} set {_playerItems::*} to all items in player's inventory if {_playerItems::*} does not contain {_acctualList::*}: send "&cNie masz potrzebnych itemów!" stop loop all players: if name of loop-player's current inventory is "Itemy: (&9%{_seller}% %{_now}%&8)": CoinFlipMenu(loop-player) StartCoinFlip("%player%" parsed as offline player, {_seller} parsed as offline player, {_acctualList::*}) remove {_acctualList::*} from player set {_object} to "object:%{_now}%" clear {CoinFlipListItems::%{_seller}%-%{_object}%::*} clear {CoinFlipList::%{_seller}%-%{_object}%} if name of event-inventory is "&8Dodaj bet!": if clicked slot is between 36 and 44: cancel event if clicked slot is 44: loop 36 times: slot loop-value - 1 of event-inventory is not air set {_x::%loop-value%} to slot loop-value - 1 of event-inventory if {_x::*} is not set: send "&cMusisz włożyć itemy do gui!" stop if {_x::*} is air: send "&cMusisz włożyć itemy do gui!" stop set {_p} to "%player%" in lowercase if {CoinFlipListItems::%{_p}%-%now%::*} is set: send "&cZwolnij trochę! Betować można co każdą minutę!" stop set slot 42 of event-inventory to air close player's inventory send title "&2Pomyślnie zbetowano dodane itemy!" set {CoinFlipListItems::%{_p}%-%now%::*} to {_x::*} set {CoinFlipList::%{_p}%-%now%} to player loop all players: if name of loop-player's current inventory is "&8Coinflip": CoinFlipMenu(loop-player) on inventory close: if name of event-inventory is "&8Dodaj bet!": if slot 42 of event-inventory is not air: loop 36 times: slot loop-value - 1 of event-inventory is not air if player have enough space for slot loop-value - 1 of event-inventory: give slot loop-value - 1 of event-inventory to player else: drop slot loop-value - 1 of event-inventory at location of player on tab complete of "/coinflip": set tab completions for position 1 to "magazyn", "bet", "open"