TransWikia.com

How can I build a 'shop' that trades score for weaponry?

Arqade Asked on June 16, 2021

I am creating an arena using command block elements to streamline and improve the combat. I am making use of a scoreboard system to track the number of kills per player. I now want to build a command-based “kill shop” in which a player may trade score for more effective weaponry. To do this, I will need to check that the buying player has enough kill points to purchase an item, remove the points, and give the item or items.

How do I go about making sure a player has at least a certain amount of points, and only then removing an exact number from their scoreboard score?

2 Answers

If you are playing on Minecraft version 1.9+, all you need to do is check that they have 32 points:

/scoreboard players test @p objectivename 32 [2000000000] 

Then have a chain command block after it with conditional on with this command in it:

/give @p minecraft:TOOLHERE 0 [amount] 

and the next chain command block with conditional on with this command in it:

/scoreboard players remove @p objectivename 32 
  • The first command block sees that they have 32 kills
  • The second will give them a diamond sword
  • The third will remove 32 kills from that player

so it can be done much simpler

Correct answer by Epb7304 on June 16, 2021

This can be done fairly easily, especially assuming you already have the scoreboard objective set up. For this example, let's assume that you're selling an item for 32 points.

The first thing you'll need in the command block chain is a pulse command block that takes score away, but only if they have enough. That can be done like so:

/scoreboard players add @p[r=3,score_kill_min=32] kill -32

This will select the nearest player (within 3 blocks) and remove 32 from their kill score as long as they have at least 32 points to spend. This will feed upward into a conditional/chain/always active command block giving them the item you want. This command block will fire if and only if this first one was successful. If the command fails to find a player with that criteria, the give command will not execute.

Answered by Unionhawk on June 16, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP