- Joined
- May 20, 2023
- Messages
- 489
First of all Set up the auction house chest - Create a variable called "auctionHouseChest" to store the location of the auction house chest.
Use a function for the auction house command like @ah sell.
Use an array called commands to store the command which will be used in order to sell a particular item. Convert the item into value and then store the value in an array.
Check if the entered command is in the "commands" array using a loop block
If the command equals "@ah sell <price>", remove the item from the player's hand and add it to the "playerItems" array.
Place the item from playerItems" into the fill container chest using the "auctionHouseChest" variable and put the location of the chest and set its name to "Auction House"
Buying items from the auction house:
Create an array called "playerBalances" to store the players' money by putting the variable of money/coin such as %player%_money but make sure to change it to %selected%.
Use a loop to check if the player has enough money to buy the item by using the "if variable" block. Deduct the price from the player's balance in the "playerBalances" array. Remove the item from the auction house chest using the "auctionHouseChest" variable, putting the variable In the remove item container thing. Give the item to the player using the same variable. You may also add sound effects when a player buys a particular item.
By the variable "auctionHouseChest" "playerItems", you can store and change the information if necessary for the auction house. If you want to make your auction house code look bigger, you may want to fill the "fill container" block with air 😉
Use a function for the auction house command like @ah sell.
Use an array called commands to store the command which will be used in order to sell a particular item. Convert the item into value and then store the value in an array.
Check if the entered command is in the "commands" array using a loop block
If the command equals "@ah sell <price>", remove the item from the player's hand and add it to the "playerItems" array.
Place the item from playerItems" into the fill container chest using the "auctionHouseChest" variable and put the location of the chest and set its name to "Auction House"
Buying items from the auction house:
Create an array called "playerBalances" to store the players' money by putting the variable of money/coin such as %player%_money but make sure to change it to %selected%.
Use a loop to check if the player has enough money to buy the item by using the "if variable" block. Deduct the price from the player's balance in the "playerBalances" array. Remove the item from the auction house chest using the "auctionHouseChest" variable, putting the variable In the remove item container thing. Give the item to the player using the same variable. You may also add sound effects when a player buys a particular item.
By the variable "auctionHouseChest" "playerItems", you can store and change the information if necessary for the auction house. If you want to make your auction house code look bigger, you may want to fill the "fill container" block with air 😉