I’m trying to make bank accounts for players in a Minecraft world. Is there a feature in Minecraft commands that would enable me to do this using variables? If so, which commands would allow me to utilise this, or if not, what would be my best option?
-
5Have you made any attempt to solve this yourself? Arqade works better when askers show effort to solve their own problems; we see that you have a problem you've worked on, and answerers respond to that. You also get a more specific answer that's tailored exactly to the part you're stuck, and Arqade gets a very specific question. Everybody wins!– FrankCommented Jun 26, 2018 at 19:53
-
Yes, I have already mentioned my attemp to solve this problem with blocks.– DM01131Commented Jul 15, 2018 at 16:42
2 Answers
Scoreboards are the tool you're looking for. All of the scoreboard commands are explained in the wiki link, but since it may be overwhelming, I'll try to present it in a more digestible format tailored to your specific needs below.
For making bank accounts, you could make a new objective for the amount of money a player has, which could be called "money". You will want this objective to be of the dummy
criteria (which is what the dummy suffix below means) because it isn't based on a preexisting Minecraft value, and you won't want players to arbitrarily control their own money.
scoreboard objectives add money dummy
Then to begin tracking a player's money:
scoreboard players add playerName money
Or better yet, use target selectors for generic player inclusion:
scoreboard players add @p money
There are many different commands to modify and evaluate a player's money. set
, add
, remove
, and test
are probably vital. They can be used as follows:
Set a player's balance to 0:
scoreboard players set playerName money 0
Add 10 to a player's balance:
scoreboard players add playerName money 10
Remove 10 from player's balance:
scoreboard players remove playerName money 10
Test if a player's balance is greater than or equal to 100:
scoreboard players test playerName money 100
Here are some other commands you can use.
In order to have a well-functioning and automatically managed bank, you'll also want to investigate command blocks. Conditional command blocks are particularly vital. Target selectors will also be necessary (as opposed to the playerName I gave in my above examples), because you shouldn't be using player names if you want a scalable system.
-
@user209814 I would also recommend reading What should I do when someone answers my question? and accepting this answer if you like it.– GrahamCommented Jun 30, 2018 at 12:57
-
Thanks, @Graham. I'm fairly new to arqade, so didn't know you could accept answers like that.– DM01131Commented Jun 30, 2018 at 19:41
-
1Scoreboards are no longer restricted to "the most recent version of minecraft"– ppperyCommented Jul 15, 2019 at 15:13
-
@pppery Since I haven't been focusing on Minecraft in the last year, I don't have full confidence in my memory of the version history and may have edited my answer inaccurately. Feel free to suggest an edit if there's anything that can be improved in my answer!– GrahamCommented Jul 21, 2019 at 11:39
Have a bank user use a "Key" that is specific to their account to access their selected currency. The key can be any item that is named. An example of this would be an apple that is named "Open". The key will have to be placed in a chest or hopper which will lead to redstone circuitry that will "unlock" the said bank account. The user will then put their goods in a chest that will put their goods away into their account before a lever is pulled and the key is dropped out again for the user.