Sooo, i want to make a shop system, but i don't want to do an if statement for every item so i came up with this code:
So now my problem is that when you buy something you get the name and lore with it (i know how to fix this), but now you can't sell something what doesn't have the name of the clicked item so how do i do this?
I mean when you craft the item you want to sell so it has the default name or you renamed it in an anvil
Code:
on right click:
if name of event-entity is "&7Schmied":
open chest with 4 rows named "&8Schmiedin" to player
loop 9 times:
set slot loop-number + 26 of player's current inventory to black stained glass pane named "&cX"
set slot 0 of player's current inventory to iron helmet named "&7Eisenhelm &a500$ &c250$" with lore "&8[&7LMB&8] &aKaufen%nl%&8[&7RMB&8] &cVerkaufen"
set slot 1 of player's current inventory to iron chestplate named "&7Eisenhelm &a750$ &c375$" with lore "&8[&7LMB&8] &aKaufen%nl%&8[&7RMB&8] &cVerkaufen"
set slot 2 of player's current inventory to iron leggings named "&7Eisenhelm &a500$ &c250$" with lore "&8[&7LMB&8] &aKaufen%nl%&8[&7RMB&8] &cVerkaufen"
set slot 3 of player's current inventory to iron boots named "&7Eisenhelm &a200$ &c100$" with lore "&8[&7LMB&8] &aKaufen%nl%&8[&7RMB&8] &cVerkaufen"
if name of event-entity is "&7Farmer":
open chest with 4 rows named "&8Farmer" to player
loop 9 times:
set slot loop-number + 26 of player's current inventory to black stained glass pane named "&cX"
if name of event-entity is "&7Bauarbeiter":
open chest with 4 rows named "&8Bauarbeiter" to player
loop 9 times:
set slot loop-number + 26 of player's current inventory to black stained glass pane named "&cX"
on inventory click:
if inventory name of player's current inventory is set:
if inventory name of player's current inventory is "&8Schmiedin":
cancel event
if clicked item is not black stained glass pane:
if clicked item is not air:
if "%click type%" contains "LEFT":
set {_name} to name of clicked item
set {_temp::*} to {_name} split at " "
set {_price} to {_temp::2}
replace "&a" with "" in {_price}
replace "$" with "" in {_price}
set {_p} to {_price} parsed as integer
if {money.%player's uuid%} is smaller than {_p}:
send "&cNicht genügend Geld"
stop
else:
remove {_p} from {money.%player's uuid%}
give player clicked item
else if "%click type%" contains "RIGHT":
set {_name} to name of clicked item
set {_temp::*} to {_name} split at " "
set {_price} to {_temp::3}
replace "&c" with "" in {_price}
replace "$" with "" in {_price}
set {_p} to {_price} parsed as integer
if player has clicked item in his inventory:
remove clicked item from player's inventory
add {_p} to {money.%player's uuid%}
else:
send "&cDu kannst das nicht verkaufen"
stop
if inventory name of player's current inventory is "&8Farmer":
cancel event
if inventory name of player's current inventory is "&8Bauarbeiter":
cancel event
So now my problem is that when you buy something you get the name and lore with it (i know how to fix this), but now you can't sell something what doesn't have the name of the clicked item so how do i do this?
I mean when you craft the item you want to sell so it has the default name or you renamed it in an anvil