im making a shop with command blocks but i need a command to make this work. i want a player to put the price of the item in the first slot of their inventory and then they click a button and the item replaces and deletes the old item. Lets say i was selling an elytra for 5 diamonds and the player would click a button and those 5 diamonds in the first slot of their hotbar would get deleted but there would be an elytra taking their place.
Then, in a conditional chain command block off of it, do:
/give @p elytra 1 0
Then another conditional:
/clear @p diamond 0 5
By this method, you don't have to have the Diamonds in the first slot.
thank you so much. sorry about the multiple threads. i posted it in creative and then realized that it was in the wrong section but i couldn't figure out how to delete it.
thank you so much. sorry about the multiple threads. i posted it in creative and then realized that it was in the wrong section but i couldn't figure out how to delete it.
Then, in a conditional chain command block off of it, do:
/give @p elytra 1 0
Then another conditional:
/clear @p diamond 0 5
By this method, you don't have to have the Diamonds in the first slot.
Be aware that this requires a stack size of exactly 5 diamonds. If the player has more than that in a stack, or if players had 5 diamonds across their inventory but not in the same stack, then it's not going to work.
If you need a minimum number of items, you have to use CommandStats to count the number of items the player has in their inventory.
Prerequisites:
Objective to hold the number of items per-player:
/scoreboard objectives add ITEMS dummy
Trigger to apply to player. If players can join at any time, this may need to run on a clock.
/stats entity @a set AffectedItems @a[c=1] ITEMS
In order for CommandStats to modify the target's score, that target must be tracked prior. May also need to be run on a clock.
/scoreboard players add @a ITEMS 0
Detection:
1. Cause the player to run a /clear command that detects the item in question. No items are removed as the maximum amount is set to 0. The result is the player's "ITEMS" score being equal to the number of diamonds they had.
(Before this block You need To place comaptor block or it wont REALLY WORK in latest verisons)
Then, in a conditional chain command block off of it, do:
/give @p elytra 1 0
Then another conditional:
/clear @p diamond 0 5
By this method, you don't have to have the Diamonds in the first slot.
im making a shop with command blocks but i need a command to make this work. i want a player to put the price of the item in the first slot of their inventory and then they click a button and the item replaces and deletes the old item. Lets say i was selling an elytra for 5 diamonds and the player would click a button and those 5 diamonds in the first slot of their hotbar would get deleted but there would be an elytra taking their place.
First, there's not a reason to have to make multiple threads about this.
Secondly, in an impulse command block, do:
Then, in a conditional chain command block off of it, do:
Then another conditional:
By this method, you don't have to have the Diamonds in the first slot.
thank you so much. sorry about the multiple threads. i posted it in creative and then realized that it was in the wrong section but i couldn't figure out how to delete it.
No problem! Glad to help!
Be aware that this requires a stack size of exactly 5 diamonds. If the player has more than that in a stack, or if players had 5 diamonds across their inventory but not in the same stack, then it's not going to work.
If you need a minimum number of items, you have to use CommandStats to count the number of items the player has in their inventory.
Prerequisites:
Objective to hold the number of items per-player:
Trigger to apply to player. If players can join at any time, this may need to run on a clock.
In order for CommandStats to modify the target's score, that target must be tracked prior. May also need to be run on a clock.
Detection:
1. Cause the player to run a /clear command that detects the item in question. No items are removed as the maximum amount is set to 0. The result is the player's "ITEMS" score being equal to the number of diamonds they had.
2. You can then target players based on their score.
Minecraft-things: http://skylinerw.com
More Minecraft-things: https://sourceblock.net
Guides for command-related features (eventually moving to Source Block): https://github.com/skylinerw/guides
I primarily hang out in the /r/MinecraftCommands discord, where there's a lot of people that help with commands: https://discord.gg/QAFXFtZ
Their corresponding subreddit: https://www.reddit.com/r/MinecraftCommands/
Awesome, I knew mine had that limitation but I wasn't too sure of how to get past that. Thanks for the help!
Ok Speaking of The testfor Minecraft Allows Compators to only do that!
Cealry YOu dont know The Wae!
How to fix the shop?
When I put /clear @p gold_ingot 0 5
And the second one is /give @p diamond 1
But my friend can have only 4 gold ingot he can still use it
PS sorry for the grammar stuff I'm.not good in English
I think you just need to do /clear @p gold_ingot 5
My channel - ALMOST AT 200 SUBSCRIBERS! https://www.youtube.com/channel/UCGZEwCcmu-lZetoA5hmte6g?view_as=subscriber