function tradeStart(p1: player, p2: player): open chest with 2 rows named "&lTrade | %{_p2}%" to {_p1} open chest with 2 rows named "&lTrade | %{_p1}%" to {_p2} set {Player.trade::%{_p1}%} to "%{_p2}%" set {Player.trade::%{_p2}%} to "%{_p1}%" clear {Player.trade.items.%{_p1}%::*} clear {Player.trade.items.%{_p2}%::*} clear {Player.trade.finish::%{_p1}%} clear {Player.trade.finish::%{_p2}%} clear {Player.tradewaiting::%{_p1}%} clear {Player.tradewaiting::%{_p2}%} function tradeWait(p1: player, p2: player): open chest with 6 rows named "&lTrade | Waiting for %{_p2}%" to {_p1} set {_} to 0 loop 18 times: set slot {_} of {_p1}'s current inventory to {Player.trade.items.%{_p2}%::%{_}%} add 1 to {_} set {_} to 18 loop 9 times: set slot {_} of {_p1}'s current inventory to black glass pane named "&c⇡ &ePrzedmioty gracza %{_p2}%" with lore "&c⇣ &eTwoje przedmioty" add 1 to {_} set {_} to 45 loop 2 times: loop 3 times: set slot {_} of {_p1}'s current inventory to black glass pane named " " add 1 to {_} add 3 to {_} set slot 48 of {_p1}'s current inventory to rose red named "&4✘ &cPrzerwij transakcje &4✘" set slot 49 of {_p1}'s current inventory to empty map named "&e&lStatus transakcji" with lore "&7%{_p1}%&8: &c✘", "&7%{_p2}%&8: &c✘" set slot 50 of {_p1}'s current inventory to light green dye named "&2✔ &aZaakceptuj transakcje &2✔" set {_} to 27 set {_!} to 0 loop 18 times: set slot {_} of {_p1}'s current inventory to {Player.trade.items.%{_p1}%::%{_!}%} add 1 to {_} add 1 to {_!} if uncolored inventory name of {_p2}'s current inventory is "Trade | Waiting for %{_p1}%": set {_} to 0 loop 18 times: set slot {_} of {_p2}'s current inventory to {Player.trade.items.%{_p1}%::%{_}%} add 1 to {_} set slot 49 of {_p1}'s current inventory to slot 49 of {_p2}'s current inventory function stopTrade(p1: player): if {Player.trade::%{_p1}%} is set: set {_} to 0 loop 18 times: add {Player.trade.items.%{_p1}%::%{_}%} to {_p1} add 1 to {_} clear {Player.trade::%{_p1}%} function finishTrade(p1: player, p2: player): set {Player.trade.finish::%{_p1}%} to true set {Player.trade.finish::%{_p2}%} to true {_p1}.closeInventory() {_p2}.closeInventory() set {_} to 0 loop 18 times: add {Player.trade.items.%{_p2}%::%{_}%} to {_p1} add {Player.trade.items.%{_p1}%::%{_}%} to {_p2} add 1 to {_} send "&2&lSuccess! &aTransakcja zostala zakonczona sukcesem!" to {_p1} send "&2&lSuccess! &aTransakcja zostala zakonczona sukcesem!" to {_p2} on inventory click: if inventory name of player's current inventory is "&lTrade | Waiting for %{Player.trade::%player%}%": cancel event if clicked item is light green dye named "&2✔ &aZaakceptuj transakcje &2✔": set {_p2} to {Player.trade::%player%} parsed as offlineplayer set slot 49 of player's current inventory to empty map named "&e&lStatus transakcji" with lore "&7%player%&8: &a✔", "&7%{_p2}%&8: &c✘" if inventory name of {_p2}'s current inventory is "&lTrade | Waiting for %player%": set slot 49 of {_p2}'s current inventory to empty map named "&e&lStatus transakcji" with lore "&7%{_p2}%&8: &c✘", "&7%player%&8: &a✔" set slot 50 of player's current inventory to black glass pane named " " if slot 50 of player's current inventory is black glass pane named " ": if slot 50 of {_p2}'s current inventory is black glass pane named " ": finishTrade(player, {_p2}) if clicked item is rose red named "&4✘ &cPrzerwij transakcje &4✘": player.closeInventory() on inventory close: if uncolored inventory name of player's current inventory contains "Trade": set {_n} to uncolored inventory name of player's current inventory if {_n} is "Trade | Waiting for %{Player.trade::%player%}%": if {Player.trade.finish::%player%}: stop set {_p1} to player set {_p2} to {Player.trade::%player%} parsed as player stopTrade({_p1}) if inventory name of {_p2}'s current inventory is "&lTrade | %player%": {_p2}.closeInventory() wait 2 tick {_p2}.closeInventory() else: {_p2}.closeInventory() send "&4&lError! &cWymiana zostala przerwana!" to {_p1} else: if {Player.trade::%player%} is set: set {_} to 0 loop 18 times: if slot {_} of player's current inventory is not air: set {Player.trade.items.%player%::%{_}%} to slot {_} of player's current inventory add 1 to {_} wait 1 tick tradeWait(player, {Player.trade::%player%} parsed as offlineplayer) command /trade []: cooldown: 5 seconds cooldown message: &4&lError! &cTa komende mozesz uzywac co 5 sekund! cooldown bypass: damianekrpg.bypass.trade trigger: if {Player.tradewaiting::%player%} is not player-arg: set {Player.tradewaiting::%player%} to player-arg if {Player.tradewaiting::%player-arg%} is not player: send "&2&lSuccess! &aZaprosiles gracza &e%player-arg%&a do transakcji!" to player send "&6&lWarning! &eOtrzymales zaproszenie do transakcji od gracza &c%player%&e!" to player-arg if {Player.tradewaiting::%player-arg%} is player: tradeStart(player, player-arg) on right click on player: if player is sneaking: set {_online} to name of clicked entity if {_online} parsed as offlineplayer is online: make player execute command "trade %{_online}%"