Creative+ Marketplace/"Auction house" (Guide)

sprinkler

Member
Joined
May 19, 2023
Messages
26
Set an initial value of "Slot" (SAVED) Variable to -1

chat event -> if contains @mp sell and if player not holding air call function "Sell" (1)

Function Sell (1): If Slot variable not equals 54, split player message into elements, get element from third index of the split (which is the price) , if element does NOT contain alphabets [ All characters from a to z] and if element is more than 0 and less than 9999999, Increase Slot by 1 -> set variable %player% item to Current Item.
Set variable combine text %player% combine 1 to "Name : %default%" and set variable combine text %player% combine 2 to "Price : [variable used to save output of third index]. Set variable %player% item edited to current item. Set variable Add item description, save output variable as %player% item edited, Put "%player% item edited" on the Item slot as well and on the text slot place %player% combine 1 variable. Then place another set variable add item description, place the "%player% item edited" on the output and item slot and %player% combine 2 in the text slot. Game action set container item place the chest location in location slot. %player% item edited in the item variable slot and Slot variable in the place where you put the slot number. Followed by placing four append element block. First append put "Items" array (Saved) and place %player% item variable to value. Second append place "Owner" array (SAVED) and set value to current name. Third append place "Price" array (SAVED) and set value to the third element we retrieved earlier from split text. Fourth append place "EditedItems" (SAVED) and set value to "%player% item edited" and place player action set item in hand (main hand) [ leave slot empty].

Player Event click inventory. Player if inventory name equals "MarketPlace". If player item NOT equals (Chest empty) [Prevents people from clicking empty slots]. Place set variable addition. Save the value of Clicked Slot + 1 to %player% temp [ Syncs the clicked slot and array index] [ Arrays starts at 1, chest slot starts at 0, hence the increment]. Get array element from "EditedItems", index as %player% temp, output as %player% check inv. If variable %player% check inv == Clicked slot. [ Explanation: While having the MarketPlace chest open, a player can click on HIS OWN inventory and that still will run the code, This check prevents it by checking if the clicked item is equal to the item in the array]. Get element Array name : "Owner", index as %player% temp and output as %player% check owner. If variable %player% check owner NOT EQUALS to Current name/default. Call function Buy (2) [ Dont forget to add cancel event at if inv name equals MarketPlace -> cancel.

Function Buy (2): Get element Array: "Price", index as %player% temp, output as %player% asking price. If variable %player% money (SAVED) more/equal to %player% asking price. Decrement %player% money by %player% asking price. Get element Array "Items", index as %player% temp , output as %player% buying item. Player action close inventory. Player action give variable ( %player% buying item). Game action Set container (Location : MarketPlace chest ). Slot as clicked slot. Spawn entity (Villager , loc at a hidden place, name as %player% check owner). Select object entities by condition by name equals %player% check owner. Increment %selected% money by %default% asking price. Player action Delete entity (SELECTION) . Select object default player. Four delete array blocks. Fill the chest with arrays: Item, Price, Owner, Edited Items and set the index to be %default% temp. Decrement Slot var by 1. Call Function: Refresher (3)

Function Refresher (3): Get length of array, array: Price, output var: array.len. Set variable slot.clicked to 0. Set var array.index to 1. Empty container (loc:MarketPlace chest). Call function RefreshLoop (4)

Function RefreshLoop (4): If variable compare array.index less/equal than array.len. Get element from array:EditedItems, index as array.index, output:var temp. Set container item, Item variable : var temp, location: Chest, slot: var slot.clicked. Increment slot.clicked by 1. Increment array.index by 1. Wait 0.5 tick. Call function RefreshLoop (4)

This is just a base code. I believe the code fully works, if it doesnt, likely due to any error while typing here. THIS IS NOT AN AUCTION. All arrays except Split message one , are SAVED. the global var "Slot" IS ALSO SAVED

Just a heads up, if your world contains other fast loops, it's better to increase the wait from 0.5 to 1 tick. if the chest is full, it will take just about 3 seconds to fully refresh (at 1 tick). You may add a condition to check If variable updating Not equals true-> open inv on the @mp view cmd.

Edit:
Credits to veddnt too for helping me out
 
Last edited:

veddnt

Active member
Joined
Jun 2, 2023
Messages
178
theres nothing wrong with reading my old forum post except if u stole the idea of mine and u started expanding the view point of it without giving credits
wher did i stole your idea mate? its just that i thought you were asking a question...It's just a small misunderstanding, no need to make it a big drama or smth smh
 

Hmm___yeaHh

New member
Joined
Jun 20, 2023
Messages
3
Set an initial value of "Slot" (SAVED) Variable to -1

chat event -> if contains @mp sell and if player not holding air call function "Sell" (1)

Function Sell (1): If Slot variable not equals 54, split player message into elements, get element from third index of the split (which is the price) , if element does NOT contain alphabets [ All characters from a to z] and if element is more than 0 and less than 9999999, Increase Slot by 1 -> set variable %player% item to Current Item.
Set variable combine text %player% combine 1 to "Name : %default%" and set variable combine text %player% combine 2 to "Price : [variable used to save output of third index]. Set variable %player% item edited to current item. Set variable Add item description, save output variable as %player% item edited, Put "%player% item edited" on the Item slot as well and on the text slot place %player% combine 1 variable. Then place another set variable add item description, place the "%player% item edited" on the output and item slot and %player% combine 2 in the text slot. Game action set container item place the chest location in location slot. %player% item edited in the item variable slot and Slot variable in the place where you put the slot number. Followed by placing four append element block. First append put "Items" array (Saved) and place %player% item variable to value. Second append place "Owner" array (SAVED) and set value to current name. Third append place "Price" array (SAVED) and set value to the third element we retrieved earlier from split text. Fourth append place "EditedItems" (SAVED) and set value to "%player% item edited" and place player action set item in hand (main hand) [ leave slot empty].

Player Event click inventory. Player if inventory name equals "MarketPlace". If player item NOT equals (Chest empty) [Prevents people from clicking empty slots]. Place set variable addition. Save the value of Clicked Slot + 1 to %player% temp [ Syncs the clicked slot and array index] [ Arrays starts at 1, chest slot starts at 0, hence the increment]. Get array element from "EditedItems", index as %player% temp, output as %player% check inv. If variable %player% check inv == Clicked slot. [ Explanation: While having the MarketPlace chest open, a player can click on HIS OWN inventory and that still will run the code, This check prevents it by checking if the clicked item is equal to the item in the array]. Get element Array name : "Owner", index as %player% temp and output as %player% check owner. If variable %player% check owner NOT EQUALS to Current name/default. Call function Buy (2) [ Dont forget to add cancel event at if inv name equals MarketPlace -> cancel.

Function Buy (2): Get element Array: "Price", index as %player% temp, output as %player% asking price. If variable %player% money (SAVED) more/equal to %player% asking price. Decrement %player% money by %player% asking price. Get element Array "Items", index as %player% temp , output as %player% buying item. Player action close inventory. Player action give variable ( %player% buying item). Game action Set container (Location : MarketPlace chest ). Slot as clicked slot. Spawn entity (Villager , loc at a hidden place, name as %player% check owner). Select object entities by condition by name equals %player% check owner. Increment %selected% money by %default% asking price. Player action Delete entity (SELECTION) . Select object default player. Four delete array blocks. Fill the chest with arrays: Item, Price, Owner, Edited Items and set the index to be %default% temp. Decrement Slot var by 1. Call Function: Refresher (3)

Function Refresher (3): Get length of array, array: Price, output var: array.len. Set variable slot.clicked to 0. Set var array.index to 1. Empty container (loc:MarketPlace chest). Call function RefreshLoop (4)

Function RefreshLoop (4): If variable compare array.index less/equal than array.len. Get element from array:EditedItems, index as array.index, output:var temp. Set container item, Item variable : var temp, location: Chest, slot: var slot.clicked. Increment slot.clicked by 1. Increment array.index by 1. Wait 0.5 tick. Call function RefreshLoop (4)

This is just a base code. I believe the code fully works, if it doesnt, likely due to any error while typing here. THIS IS NOT AN AUCTION. All arrays except Split message one , are SAVED. the global var "Slot" IS ALSO SAVED

Just a heads up, if your world contains other fast loops, it's better to increase the wait from 0.5 to 1 tick. if the chest is full, it will take just about 3 seconds to fully refresh (at 1 tick). You may add a condition to check If variable updating Not equals true-> open inv on the @mp view cmd.

Edit:
Credits to veddnt too for helping me out
Set the initial value of the "Slot" (SAVED) variable to -1.

Chat event: If it contains "@mp sell" and if the player is not holding air, call the function "Sell" (1).

Function Sell (1):
If the Slot variable does not equal 54, split the player's message into elements. Get the element from the third index of the split (which is the price). If the element does NOT contain any alphabets (characters from 'a' to 'z') and if the element is greater than 0 and less than 9999999:
- Increase the Slot by 1.
- Set the %player% item variable to the current item.
- Set the combined text variable %player% combine 1 to "Name: %default%".
- Set the combined text variable %player% combine 2 to "Price: [variable used to save the output of the third index]".
- Set the %player% item edited variable to the current item.
- Set the item description variable by adding the output to %player% item edited.
- Put "%player% item edited" on the item slot and %player% combine 1 in the text slot.
- Add another item description variable by putting "%player% item edited" on the output and item slot, and %player% combine 2 in the text slot.
- Use the game action "set container item" and place the chest location in the location slot, %player% item edited in the item variable slot, and the Slot variable in the slot number.
- Followed by four "append element" blocks:
1. Append the "Items" array (SAVED) and place the %player% item variable as the value.
2. Append the "Owner" array (SAVED) and set the value to the current name.
3. Append the "Price" array (SAVED) and set the value to the third element retrieved earlier from the split text.
4. Append the "EditedItems" array (SAVED) and set the value to "%player% item edited".
- Place the player action "set item in hand" (main hand) [leave the slot empty].

Player Event: Click inventory.
If the player's inventory name equals "MarketPlace" and the player's item does not equal (Chest empty) [to prevent clicking empty slots]:
- Set a variable addition and save the value of the Clicked Slot + 1 to the %player% temp variable [syncs the clicked slot and array index].
- Get the array element from "EditedItems" with an index of %player% temp, output as %player% check inv.
- If the variable %player% check inv equals the Clicked Slot, do the following:
- Get the element from the "Owner" array with an index of %player% temp and output as %player% check owner.
- If the variable %player% check owner is not equal to the current name/default, call the function Buy (2) [don't forget to add a cancel event if the inventory name equals "MarketPlace" -> cancel].

Function Buy (2):
- Get the element from the "Price" array with an index of %player% temp, output as %player% asking price.
- If the variable %player% money (SAVED) is greater than or equal to %player% asking price:
- Decrement %player% money by %player% asking price.
- Get the element from the "Items" array with an index of %player% temp, output as %player% buying item.
- Close the player's inventory.
- Give the player the %player% buying item.
- Use the game action "set container" (Location: MarketPlace chest) and set the slot as the clicked slot.
- Spawn a Villager entity at a hidden place with the name %player% check owner.
- Select the entity by name equals %player% check owner.
- Increment the %selected% money by the %default% asking price.
- Delete the entity (SELECTION).
- Select the default player.
- Delete the four array blocks.
- Fill the chest with arrays: Item, Price, Owner, and EditedItems, and set the index to be %default% temp.
- Decrement the Slot variable by 1.
- Call the function Refresher (3).

Function Refresher (3):
- Get the length of the "Price" array and output it to the array.len variable.
- Set the variable slot.clicked to 0.
- Set the array.index variable to 1.
- Empty the container (location: MarketPlace chest).
- Call the function RefreshLoop (4).

Function RefreshLoop (4):
- If the variable array.index is less than or equal to array.len:
- Get the element from the "EditedItems" array with an index of array.index and output to the temp variable.
- Set the container item, item variable: temp, location: Chest, slot: slot.clicked.
- Increment the slot.clicked by 1.
- Increment the array.index by 1.
- Wait for 0.5 ticks.
- Call the function RefreshLoop (4).

Note: This is just a base code. I believe the code is fully functional. If there are any errors, they may be due to typos or formatting issues. Please note that this is not an auction. All arrays, except the split message one, are SAVED. The global variable "Slot" is also SAVED.

Just a heads up: If your world contains other fast loops, it's better to increase the wait time from 0.5 to 1 tick. If the chest is full, it will take approximately 3 seconds to fully refresh (at 1 tick). You may add a condition to check if the variable "updating" does not equal true when opening the inventory on the "@mp view" command.

HERE IS IT IN SIMPLE WORDS I HOPE U LIKE IT :)
 

Parodies

Member
Joined
Aug 26, 2023
Messages
27
Set an initial value of "Slot" (SAVED) Variable to -1

chat event -> if contains @mp sell and if player not holding air call function "Sell" (1)

Function Sell (1): If Slot variable not equals 54, split player message into elements, get element from third index of the split (which is the price) , if element does NOT contain alphabets [ All characters from a to z] and if element is more than 0 and less than 9999999, Increase Slot by 1 -> set variable %player% item to Current Item.
Set variable combine text %player% combine 1 to "Name : %default%" and set variable combine text %player% combine 2 to "Price : [variable used to save output of third index]. Set variable %player% item edited to current item. Set variable Add item description, save output variable as %player% item edited, Put "%player% item edited" on the Item slot as well and on the text slot place %player% combine 1 variable. Then place another set variable add item description, place the "%player% item edited" on the output and item slot and %player% combine 2 in the text slot. Game action set container item place the chest location in location slot. %player% item edited in the item variable slot and Slot variable in the place where you put the slot number. Followed by placing four append element block. First append put "Items" array (Saved) and place %player% item variable to value. Second append place "Owner" array (SAVED) and set value to current name. Third append place "Price" array (SAVED) and set value to the third element we retrieved earlier from split text. Fourth append place "EditedItems" (SAVED) and set value to "%player% item edited" and place player action set item in hand (main hand) [ leave slot empty].

Player Event click inventory. Player if inventory name equals "MarketPlace". If player item NOT equals (Chest empty) [Prevents people from clicking empty slots]. Place set variable addition. Save the value of Clicked Slot + 1 to %player% temp [ Syncs the clicked slot and array index] [ Arrays starts at 1, chest slot starts at 0, hence the increment]. Get array element from "EditedItems", index as %player% temp, output as %player% check inv. If variable %player% check inv == Clicked slot. [ Explanation: While having the MarketPlace chest open, a player can click on HIS OWN inventory and that still will run the code, This check prevents it by checking if the clicked item is equal to the item in the array]. Get element Array name : "Owner", index as %player% temp and output as %player% check owner. If variable %player% check owner NOT EQUALS to Current name/default. Call function Buy (2) [ Dont forget to add cancel event at if inv name equals MarketPlace -> cancel.

Function Buy (2): Get element Array: "Price", index as %player% temp, output as %player% asking price. If variable %player% money (SAVED) more/equal to %player% asking price. Decrement %player% money by %player% asking price. Get element Array "Items", index as %player% temp , output as %player% buying item. Player action close inventory. Player action give variable ( %player% buying item). Game action Set container (Location : MarketPlace chest ). Slot as clicked slot. Spawn entity (Villager , loc at a hidden place, name as %player% check owner). Select object entities by condition by name equals %player% check owner. Increment %selected% money by %default% asking price. Player action Delete entity (SELECTION) . Select object default player. Four delete array blocks. Fill the chest with arrays: Item, Price, Owner, Edited Items and set the index to be %default% temp. Decrement Slot var by 1. Call Function: Refresher (3)

Function Refresher (3): Get length of array, array: Price, output var: array.len. Set variable slot.clicked to 0. Set var array.index to 1. Empty container (loc:MarketPlace chest). Call function RefreshLoop (4)

Function RefreshLoop (4): If variable compare array.index less/equal than array.len. Get element from array:EditedItems, index as array.index, output:var temp. Set container item, Item variable : var temp, location: Chest, slot: var slot.clicked. Increment slot.clicked by 1. Increment array.index by 1. Wait 0.5 tick. Call function RefreshLoop (4)

This is just a base code. I believe the code fully works, if it doesnt, likely due to any error while typing here. THIS IS NOT AN AUCTION. All arrays except Split message one , are SAVED. the global var "Slot" IS ALSO SAVED

Just a heads up, if your world contains other fast loops, it's better to increase the wait from 0.5 to 1 tick. if the chest is full, it will take just about 3 seconds to fully refresh (at 1 tick). You may add a condition to check If variable updating Not equals true-> open inv on the @mp view cmd.

Edit:
Credits to veddnt too for helping me out
🤓🫵
 
Top