Jump to content

  • Curse Sites
Become a Premium Member! Help
Latest News Article

[HELP] Item Shop using Command Blocks (NO XP CURRENCY)


  • Please log in to reply
9 replies to this topic

#1

MrOmNom
    MrOmNom

    Gold Miner

  • Members
  • 384 posts
  • Location: The internet
  • Minecraft: MrNomNom111

Posted 14 December 2012 - 05:00 AM

I'm having the infuriatingly difficult task of setting up an item shop in with command blocks. I've designed and perfected a fine Experience shop, which is well and all, but what i REALLY want is a way to buy items, WITH items.

I've tried several methods; /clear, with the right player conditions, /give, with the right conditions, and so on.

Unfortunately, they're both flawed:

1) unless the targeted player has NO OTHER items in their inventory except for the "buying" item , /clear can be cheated past, or not work at all.

2) There's the chance that /clear will wipe the entire inventory

3)For the /give, i stumbled upon a brilliant idea "I'll try /give -item-id"!!!!!!!!!! And then it turns out that you "/give" negative items, and thus subtract currency (gold, diamonds, whatever) from a player's inventory.

So, I'm wondering if anyone else out there has discovered or is working on a solution to this problem. I would love any feed back anyone has to offer.

And sorry if the above is hard to understand.

Register or log in to remove.

#2

Rimodo
    Rimodo

    Carpenter

  • Members
  • 53 posts

Posted 14 December 2012 - 12:34 PM

The function that you want is possible by using "/clear playername itemid itemcount" where the playername can of course be exchanged by tags like @p[lm=12,l=13,r=10] and stuff like that.

The only problem is that you get no detectable output from the clear command, you have no way to detect if the player has the item in his inventory only to take it if he/she has. At least not with that one single command.

What you simply can do is create custom villager shops where you can trade as example wool as tokens for on enchanted diamond sword.
Check out my Redstone Multiplayer Game Colorrage

#3

viiml
    viiml

    Coal Miner

  • Members
  • 123 posts
  • Location: Popovańća, Croatia
  • Minecraft: viliml

Posted 14 December 2012 - 06:52 PM

The only way is using buildcraft. Put items in, obsidian pipe pick is up, diamond pipe filters, if it's wrong give it back, if it's right send it to a pressure plate that activates the command block.

Posted Image


#4

MrOmNom
    MrOmNom

    Gold Miner

  • Members
  • 384 posts
  • Location: The internet
  • Minecraft: MrNomNom111

Posted 15 December 2012 - 07:25 AM

View PostRimodo, on 14 December 2012 - 12:34 PM, said:

The function that you want is possible by using "/clear playername itemid itemcount" where the playername can of course be exchanged by tags like @p[lm=12,l=13,r=10] and stuff like that.

The only problem is that you get no detectable output from the clear command, you have no way to detect if the player has the item in his inventory only to take it if he/she has. At least not with that one single command.

What you simply can do is create custom villager shops where you can trade as example wool as tokens for on enchanted diamond sword.

Thanks a TON. I've never heard of the the further sub-commands for /clear before. This changes things. However, as you noted, there is no viable way (yet) to confirm that the player holds [target] item.

But, this is a big step for me.

I have also checked out Villager shops, but I want a more automated, one-click-shop feel. If there's no other choice, I will probably use them.

View Postviiml, on 14 December 2012 - 06:52 PM, said:

The only way is using buildcraft. Put items in, obsidian pipe pick is up, diamond pipe filters, if it's wrong give it back, if it's right send it to a pressure plate that activates the command block.

Actually, I've heard rumors of the Allocator, or some sort of similar block, being implemented in 1.5.

#5

Skylinerw
    Skylinerw

    Sectional Moderator

  • Sectional Moderator
  • 3633 posts

Posted 15 December 2012 - 12:17 PM

View PostMrOmNom, on 15 December 2012 - 07:25 AM, said:



Thanks a TON. I've never heard of the the further sub-commands for /clear before. This changes things. However, as you noted, there is no viable way (yet) to confirm that the player holds [target] item.

But, this is a big step for me.

I have also checked out Villager shops, but I want a more automated, one-click-shop feel. If there's no other choice, I will probably use them.



Actually, I've heard rumors of the Allocator, or some sort of similar block, being implemented in 1.5.

As a notice, the /clear command does NOT clear a specific amount. /clear will always clear EVERY item it finds. The correct /clear command with parameters is:

/clear [player] [item ID] [damage value]

Damage values can be found on certain items such as wool, to target different colors. Item ID 373 would target every single potion in the game; adding damage values afterwards would allow you to select specific potions. But in short, there's no way to clear a specified amount of items.

#6

BrainCruncher
  • Location: Sweden
  • Minecraft: BrainCruncher

Posted 15 December 2012 - 12:22 PM

Try using villagers, sethbling has an MCedit filter for custom shops.
He also has a filter to make them unkillable.
Posted Image

#7

haschischtasche
  • Minecraft: haschischtasche

Posted 15 December 2012 - 01:55 PM

There is a 100% reliable way to detect if a player has item X in his inventory, and that works flawlessly in vanilla without any mods.
The basic concept is filling up his inventory with otherwise unobtainable items (certain potions a.e.) and then throwing him one of the items you want to detect. If he has that certain item in his inventory it will stack, if not it will fall to the ground which you can detect with a pressure plate, tripwire or whatever.

#8

Rimodo
    Rimodo

    Carpenter

  • Members
  • 53 posts

Posted 15 December 2012 - 04:24 PM

View PostSkylinerw, on 15 December 2012 - 12:17 PM, said:

As a notice, the /clear command does NOT clear a specific amount. /clear will always clear EVERY item it finds. The correct /clear command with parameters is:

/clear [player] [item ID] [damage value]

Damage values can be found on certain items such as wool, to target different colors. Item ID 373 would target every single potion in the game; adding damage values afterwards would allow you to select specific potions. But in short, there's no way to clear a specified amount of items.

Yeah that is totally right, I mixed that up, sry.

There are still ways with item detectors, but they are bulky and mostly not really reliable.
Check out my Redstone Multiplayer Game Colorrage

#9

MrOmNom
    MrOmNom

    Gold Miner

  • Members
  • 384 posts
  • Location: The internet
  • Minecraft: MrNomNom111

Posted 15 December 2012 - 11:55 PM

View PostSkylinerw, on 15 December 2012 - 12:17 PM, said:

As a notice, the /clear command does NOT clear a specific amount. /clear will always clear EVERY item it finds. The correct /clear command with parameters is:

/clear [player] [item ID] [damage value]

Damage values can be found on certain items such as wool, to target different colors. Item ID 373 would target every single potion in the game; adding damage values afterwards would allow you to select specific potions. But in short, there's no way to clear a specified amount of items.

Thanks. However, on the topic of Potion Damage Values, do you know how to /give certain potions? Looking up any "item ID" list online, they all gave the same ID's. However, whenever i tried using one, the console would give a "item value is invalid"

This was before 1.4.5, so it might have been a bug.

But i think it might be something else, because i've noticed that anything with secondary values (373:xxxx) like potions, don't work. Do you know anything on that?

#10

Skylinerw
    Skylinerw

    Sectional Moderator

  • Sectional Moderator
  • 3633 posts

Posted 16 December 2012 - 02:00 AM

View PostMrOmNom, on 15 December 2012 - 11:55 PM, said:



Thanks. However, on the topic of Potion Damage Values, do you know how to /give certain potions? Looking up any "item ID" list online, they all gave the same ID's. However, whenever i tried using one, the console would give a "item value is invalid"

This was before 1.4.5, so it might have been a bug.

But i think it might be something else, because i've noticed that anything with secondary values (373:xxxx) like potions, don't work. Do you know anything on that?

You can find a full list of potion damage values here: http://www.minecraft...et/wiki/Potions (listed in the tables as "DV").

For the give command, the parameters are in the following order:

/give [player name] [item ID] [item quantity] [damage value]

So the damage value is at the end, rather than after the item ID. So for giving a potion of regeneration, you would put:

/give [player name] 373 1 8193

Hope this helps!