function createCitizenShopGUI(t: text) :: inventory: set {_g} to chest inventory with 6 rows named {_t} set slot (integers between 0 and 53) of {_g} to white stained glass pane named " " set slot 4 of {_g} to book named "&aOpis działania" with lore "&6LPM &7- Kupno 1 sztuki", "&6ŚPM &7- Sprzedaż wszystkiego" and "&6PPM &7- Sprzedaż 1 sztuki" set {_i} to 10 loop 4 times: set slot (integers between {_i} and ({_i} + 6)) of {_g} to air add 3 to {_i} return {_g} function buyCitizenShopGUI(p: player, n: number, i: item): {_p}'s balance < {_n}: send "&cNie posiadasz wystarczająco pieniędzy!" to {_p} stop remove {_n} from {_p}'s balance give {_i} to {_p} send "&aPomyślnie zakupiłeś przedmiot!" to {_p} function sellCitizenShopGUI(p: player, n: number, i: item): {_p} doesn't have {_i}: send "&cNie posiadasz tego przedmiotu, aby móc go sprzedać!" to {_p} stop remove {_i} from {_p}'s inventory add {_n} to {_p}'s balance send "&aPomyślnie sprzedałeś przedmiot!" to {_p} function sellAllCitizenShopGUI(p: player, n: number, i: item): {_p} doesn't have {_i}: send "&cNie posiadasz tego przedmiotu, aby móc go sprzedać!" to {_p} stop set {_a} to amount of {_i} in {_p}'s inventory remove all {_i} from {_p}'s inventory add ({_a} * {_n}) to {_p}'s balance send "&aPomyślnie sprzedałeś przedmioty!" to {_p} function clickTypeCitizenShopGUI(p: player, c: click type, n1: number, n2: number, i: item): if {_c} is left mouse button: buyCitizenShopGUI({_p}, {_n1}, {_i}) else if {_c} is right mouse button: sellCitizenShopGUI({_p}, {_n2}, {_i}) else if {_c} is middle mouse button: sellAllCitizenShopGUI({_p}, {_n2}, {_i}) on right click on entity: if display name of entity is "drwal": set {_g} to createCitizenShopGUI("&a&lDrwal") set slot 10 of {_g} to oak log named "&aDębowe drewno" with lore "&bCena zakupu: &615$/szt." and "&bCena sprzedaży: &65$/szt." else if display name of entity is "gornik": set {_g} to createCitizenShopGUI("&6&lGórnik") set slot 10 of {_g} to iron ore named "&aRuda żelaza" with lore "&bCena zakupu: &650$/szt." and "&bCena sprzedaży: &630$/szt." {_g} is set open {_g} to player on inventory click: clicked inventory is not player's inventory if name of player's current inventory is "&a&lDrwal": cancel event if clicked slot is 10: clickTypeCitizenShopGUI(player, click type, 15, 5, oak log) else if name of player's current inventory is "&6&lGórnik": cancel event if clicked slot is 10: clickTypeCitizenShopGUI(player, click type, 15, 5, iron ore)