Hey guys, i am currently working on a new shop system with physical money and i need to be able to check how much gold/iron someone has in their inventory, all i've been able to find on youtube and the forums are how to check for just one of the specific item (check if they even have diamonds in their inventory, not how many they have though).
PLEASE HELP!
Thanks to anyone who replies
ps. i am using command blocks, not pressure plates or tripwires to count items. ONLY COMMAND BLOCKS.
clear @p[r=5] minecraft:gold_ingot 0 (amount item costs they buy)
That will remove a certain amount of goldingots the closest person in a radius of 5 has. Which lets say they want to buy a diamond, but it costs 5 gold ingots, you can use the command
clear @p[r=5] minecraft:gold_ingot 0 5
and then put a comparator next to it so when it does run it will then continue onto the next command, which would be /give @p[r=5] minecraft:diamond
Hey guys, i am currently working on a new shop system with physical money and i need to be able to check how much gold/iron someone has in their inventory, all i've been able to find on youtube and the forums are how to check for just one of the specific item (check if they even have diamonds in their inventory, not how many they have though).
PLEASE HELP!
Thanks to anyone who replies
ps. i am using command blocks, not pressure plates or tripwires to count items. ONLY COMMAND BLOCKS.
wait, is there a way you can test for an amount of an item?
Yes, you can use CommandStats to accomplish this. CommandStats are only available in 1.8+.
Prerequisites:
Objective to track player inventories of items.
/scoreboard objectives add ITEMS dummy
Clock Commands:
Run the following commands on a clock (the order does not matter):
/stats entity @a set AffectedItems @a[c=1] ITEMS
/scoreboard players add @a ITEMS 0
Detection Command:
This will depend on how players make their purchases. Assuming you have them click a button, you will need to activate the command to target the player who would have clicked (being the player closest to the button). Since the "AffectedItems" stat will be changed for all different items, you'll have to do this via player interaction instead of at all times on a clock.
The above setup will set the players' "ITEMS" score to the number of iron ingots in their inventory, without removing any items. You will then detect players using that score. For example, detecting if a player has at least 20 iron:
Pulse the first one, and the second one will place the results in the ITEMS objective; then test as before. Note, of course, in the second block you may need to adjust the XYZ coordinates/etc (the coordinates point at the first block). And you'll have had to instantiate the ITEMS objective and set it on the player, too.
Skylinerw's technique can be optimized w/o a clock using two command blocks chained together:
clear @p minecraft:iron_ingot 0 0
stats block ~ ~ ~1 set AffectedItems @p ITEMS
Pulse the first one, and the second one will place the results in the ITEMS objective; then test as before. Note, of course, in the second block you may need to adjust the XYZ coordinates/etc (the coordinates point at the first block). And you'll have had to instantiate the ITEMS objective and set it on the player, too.
The major difference in that is the inability to support multiple players. If you looking for any player that had a specific amount of items in their inventory, your method could not be used; not even if you replaced @p with @a. The /clear command cycles through, and the CommandStats will only reflect the last player to have been affected by the command.
For example, if I were trying to find if either of 2 players had 10 iron ingots, while one player had 5 and one had 10, the player with 5 ingots could be the last result. CommandStats would only show a score of 5, even though there's a player with 10. Using CommandStats on players ensures multiplayer support, but requires extra upkeep to ensure all players are issued the stats (of course, those commands could also be issued at the same time as detection, but would start requiring more and more command blocks if you have further detection being needed).
And have a look at the first tag. I'm not sure if you need to test for values greater than the cost, but if you do, you will most likely need multiple command blocks.
I wanted to use this in the same way, but i can't get it working when filling in exactly the same things into commandblocks, what could i do possibly wrong?
I set a sidebar display to see if the value changes, but it stays at 0.
Note: This thread was started at the end of last year most of the people probably unfollowed this thread already but luckily I look for people to help so I caught this one lol. For your problem, I don't use the stats so I don't know my way around them yet, but if you could give this a try. I have a method that uses only 4 command blocks and it looks something like this.
you could use a fast clock with /testfor @p[~,~,~,r=0] testing if a player is in like a store or something then do /testfor @p {SelectedItemSlot:0b}
then have a specif slot for money in there hot bar then if they go to a cash register and you are testing there rotation and they look ina certin direction the do /clear @p <Item Name> 1 again and again till the price is paid
Is the OP still actively seeking an answer for this? I have made a shop that does exactly what you want. Mine takes gold nuggets as currency and requires a certain amount before it will give the desired item. Example; 20 coins (nuggets) for 1 diamond. If you're still looking for an answer, I'd be more than happy to show you what I've done to make this work.
Yes, you can use CommandStats to accomplish this. CommandStats are only available in 1.8.
Prerequisites:
Objective to track player inventories of items.
/scoreboard objectives add ITEMS dummy
Clock Commands:
Run the following commands on a clock (the order does not matter):
/stats entity @a set AffectedItems @p ITEMS
/scoreboard players add @a ITEMS 0
Detection Command:
This will depend on how players make their purchases. Assuming you have them click a button, you will need to activate the command to target the player who would have clicked (being the player closest to the button). Since the "AffectedItems" stat will be changed for all different items, you'll have to do this via player interaction instead of at all times on a clock.
The above setup will set the players' "ITEMS" score to the number of iron ingots in their inventory, without removing any items. You will then detect players using that score. For example, detecting if a player has at least 20 iron:
/testfor @a[score_ITEMS_min=20]
i used this method for a shop that im trying to design and its working except the comparator that leads from the command block that detects it to the command block that clears there inventory of x amount of x item and gives them the desired item is continuously staying on unless i edit the command block and change it back, any tips or ideas on what to do?
Yes, you can use CommandStats to accomplish this. CommandStats are only available in 1.8.
Prerequisites:
Objective to track player inventories of items.
/scoreboard objectives add ITEMS dummy
Clock Commands:
Run the following commands on a clock (the order does not matter):
/stats entity @a set AffectedItems @p ITEMS
/scoreboard players add @a ITEMS 0
Detection Command:
This will depend on how players make their purchases. Assuming you have them click a button, you will need to activate the command to target the player who would have clicked (being the player closest to the button). Since the "AffectedItems" stat will be changed for all different items, you'll have to do this via player interaction instead of at all times on a clock.
The above setup will set the players' "ITEMS" score to the number of iron ingots in their inventory, without removing any items. You will then detect players using that score. For example, detecting if a player has at least 20 iron:
/testfor @a[score_ITEMS_min=20]
... either I'm stupid or...? I don't get it help im not trying to make a shop but just detect the items wouldn't your system clear the items?? help/clearify pls
Excuse me, skylinerw? I tried using your method to no avail, and would like to know how to fix this.
I am trying to make a system that gives a player an ender pearls every 5 seconds until they have a maximum of 5, but have no idea how. Your method didn't work for me, and I even tried different combinations of /testfor with items. I copied your exact notations, and nothing happened. I would like some help, if possible. Thanks in advance.
Excuse me, skylinerw? I tried using your method to no avail, and would like to know how to fix this.
I am trying to make a system that gives a player an ender pearls every 5 seconds until they have a maximum of 5, but have no idea how. Your method didn't work for me, and I even tried different combinations of /testfor with items. I copied your exact notations, and nothing happened. I would like some help, if possible. Thanks in advance.
You will need to provide any errors or specific unexpected behavior.
is there a way to put that with a different command like the command block will test for any player with leather boots and give players with leather boots invisibility
PLEASE HELP!
Thanks to anyone who replies
ps. i am using command blocks, not pressure plates or tripwires to count items. ONLY COMMAND BLOCKS.
clear @p[r=5] minecraft:gold_ingot 0 (amount item costs they buy)
That will remove a certain amount of goldingots the closest person in a radius of 5 has. Which lets say they want to buy a diamond, but it costs 5 gold ingots, you can use the command
clear @p[r=5] minecraft:gold_ingot 0 5
and then put a comparator next to it so when it does run it will then continue onto the next command, which would be /give @p[r=5] minecraft:diamond
.
Yes, you can use CommandStats to accomplish this. CommandStats are only available in 1.8+.
Prerequisites:
Objective to track player inventories of items.
Clock Commands:
Run the following commands on a clock (the order does not matter):
Detection Command:
This will depend on how players make their purchases. Assuming you have them click a button, you will need to activate the command to target the player who would have clicked (being the player closest to the button). Since the "AffectedItems" stat will be changed for all different items, you'll have to do this via player interaction instead of at all times on a clock.
Summary:
The above setup will set the players' "ITEMS" score to the number of iron ingots in their inventory, without removing any items. You will then detect players using that score. For example, detecting if a player has at least 20 iron:
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/
This really helped
Pulse the first one, and the second one will place the results in the ITEMS objective; then test as before. Note, of course, in the second block you may need to adjust the XYZ coordinates/etc (the coordinates point at the first block). And you'll have had to instantiate the ITEMS objective and set it on the player, too.
The major difference in that is the inability to support multiple players. If you looking for any player that had a specific amount of items in their inventory, your method could not be used; not even if you replaced @p with @a. The /clear command cycles through, and the CommandStats will only reflect the last player to have been affected by the command.
For example, if I were trying to find if either of 2 players had 10 iron ingots, while one player had 5 and one had 10, the player with 5 ingots could be the last result. CommandStats would only show a score of 5, even though there's a player with 10. Using CommandStats on players ensures multiplayer support, but requires extra upkeep to ensure all players are issued the stats (of course, those commands could also be issued at the same time as detection, but would start requiring more and more command blocks if you have further detection being needed).
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/
http://minecraft.gamepedia.com/Player.dat_Format#Item_structure
And have a look at the first tag. I'm not sure if you need to test for values greater than the cost, but if you do, you will most likely need multiple command blocks.
Note: This thread was started at the end of last year most of the people probably unfollowed this thread already but luckily I look for people to help so I caught this one lol. For your problem, I don't use the stats so I don't know my way around them yet, but if you could give this a try. I have a method that uses only 4 command blocks and it looks something like this. Hope this helps!!
I like to help and howl and laugh all day XD
What do NOT say to get in trouble HERE!!!
My Blog
then have a specif slot for money in there hot bar then if they go to a cash register and you are testing there rotation and they look ina certin direction the do /clear @p <Item Name> 1 again and again till the price is paid
Is the OP still actively seeking an answer for this? I have made a shop that does exactly what you want. Mine takes gold nuggets as currency and requires a certain amount before it will give the desired item. Example; 20 coins (nuggets) for 1 diamond. If you're still looking for an answer, I'd be more than happy to show you what I've done to make this work.
i used this method for a shop that im trying to design and its working except the comparator that leads from the command block that detects it to the command block that clears there inventory of x amount of x item and gives them the desired item is continuously staying on unless i edit the command block and change it back, any tips or ideas on what to do?
... either I'm stupid or...? I don't get it help im not trying to make a shop but just detect the items wouldn't your system clear the items?? help/clearify pls
Excuse me, skylinerw? I tried using your method to no avail, and would like to know how to fix this.
I am trying to make a system that gives a player an ender pearls every 5 seconds until they have a maximum of 5, but have no idea how. Your method didn't work for me, and I even tried different combinations of /testfor with items. I copied your exact notations, and nothing happened. I would like some help, if possible. Thanks in advance.
I only believe in the biggest business.
You will need to provide any errors or specific unexpected behavior.
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/
Oops, my bad. I hadn't put the final two commands on the same button. Thanks for replying anyhow.
I only believe in the biggest business.
is there a way to put that with a different command like the command block will test for any player with leather boots and give players with leather boots invisibility