So i want to make a buy feature where the player type their own numbers via message, the function work properly but i cant make the message part work. i'm stuck with this code:
i was going to make it via sign but too much work.
Python:
#Buy Function
function buy(p: player, amount: number, price: number, item: item):
if {_price} > balance of {_p}:
send "&cYou don't have enough money!" to {_p}
stop
else:
remove {_price} * {_amount} from balance of {_p}
give {_amount} of {_item} to {_p}
send "&7You bought %{_amount}% %{_item}% for $%{_price}%" to {_p}
#Defining {_message}
on chat:
set {_message} to message
#Creating the GUI
on load:
create a new gui with id "reworkshop" with virtual chest inventory with 2 rows named "reworkedshop" and shape "xxxabcxxx" and "xxxdefxxx":
make gui slot "a" with dirt named "Blocks":
open gui with id "blocks" for player
create a new gui with id "blocks" with virtual chest inventory with 2 rows named "Blocks" and shape "xxxabcxxx" and "xxxdefxxx":
make gui slot "a" with dirt named "Dirt":
create a new gui with virtual chest inventory with 1 row named "Buy or Sell" and shape "xxxaxbxxx":
make gui slot "a" with dirt named "Buy":
create a new gui with virtual chest inventory with 1 row named "Buy" and shape "xaxxbxxcx":
#The Button for 1 stack
make gui slot "a" with dirt named "Buy 1 Stack":
buy(player, 64, 1, (Dirt))
#The Button for 1 item
make gui slot "b" with dirt named "Buy 1":
buy(player, 1, 1, (Dirt))
#The Button for custom to type the amount
make gui slot "c" with oak sign named "Custom":
close player's inventory
send "&7Type the amount of items you want to buy."
if {_message} is a number:
cancel event
add {_message} parsed as number to {_amount}
buy(player, {_amount}, 1, (Dirt))
open the last gui for player
open the last gui for player
#The Command to open the GUI
command /reworkshop:
trigger:
open gui with id "reworkshop" for player
i was going to make it via sign but too much work.