0
Adding Currency System Using Scoreboard Command
The scoreboard command is a very useful command when tracking certain criteria for example Deaths, Health or Levels but for this tutorial i'll be using the Dummy criteria.
You can get a fancy Tellraw display name using this website here for this tutorial i will be using
["",{"text":"[ Money ]","bold":true,"color":"green"}]
Once you have your new objective we have to display it, There are many ways you can display your new objective Sidebar, List , Belowname.
Once you display your Objective don't be alarmed when you see nothing happen you have to now add a value to a player this can be done using.
Likewise you can remove Scores too using
Awesome! you now have the ground work for this tutorial! Now ill tell you how to integrate this into your shopping system
Shop Interface
Now lets add a Interface instead of using a button or lever ill be adding a clickable sign that will do 2 things setblock a couple blocks underneath the sign and Tag the person who clicks the sign. This website is extremely useful.
On this website Add text to your sign (Doesn't matter what you write)
Then scroll down til you see: Commands Minecraft runs when a player click on the sign:
The “/Setblock ~ ~-3 ~ minecraft:redstone_block replace” places a redstone block 3 blocks down; you can change how far down you would like to place the block; this command will be useful later.
The “/tag @s add AuthItem” gives the player who right clicks the sign a tag of your choice, I do Auth and then the item for example AuthDiamond, But you can call this tag anything you like.
Then copy the command generated and paste it into a command block and power it to get your sign. Then place the sign where-ever you would like your Interface to be. (Depending on where you put it change how far down the redstone block is placed.
There! That's all you need for the Sign now onto the command blocks.
Adding The Buy System
Now in this section it can get confusing so ill try and word it to make it is as understandable as possible.
There are 7 Command blocks that make up this system labeled here
Command Block 1:
Once you click the Sign it places a redstone block for mine it places it 3 blocks down then right below the redstone block place an Always Active, Repeating, Unconditional Command Block. With "/setblock ~ ~1 ~ air replace" This instantly removes the redstone block once it was placed.
Command Block 2:
In this command block we are defining the price and who can buy, and also telling the user if they don’t have enough funds.
It could look confusing so lets break it down
As we can see in this command we use
And we use a similar looking command
So $30 is our price and it will only work if the player has $30 and if it detects that the player has $29 for less it will say "You Don't The Funds!" (Also feel free to change the price)
We also see tag=AuthDiamond and that is the Tag you added in your sign make sure if you changed your tag name keep it the same.
And the command block is Impulse, Unconditional and Needs Redstone.
Command Block 3:
This command block gives the Player 1 diamond if the players Money is $30 or more and if the Player has the AuthDiamond tag
And the command block is Chain, Unconditional and Always Active.
Command Block 4:
This command block tells the Player "Thanks for your purchase!" while still checking if the player has $30 or more and if the player has the AuthDiamond tag.
And the command block is Chain, Unconditional and Always Active
Command Block 5:
In this command block we are playing a sound for a successful purchase while still checking if the player has $30 or more and if the player has the AuthDiamond tag.
Also the volume is controlled by master volume.
This command block is Chain, Unconditional and Always Active
Command Block 6:
This command block will take away your funds while still checking if the player has $30 or more and if the player has the AuthDiamond tag.
This command block is Chain, Unconditional and Always Active
Command Block 7
This command block removes the AuthDiamond tag.
This command block is Chain, Unconditional And Always Active
Adding The Sell System
The sell system is pretty similar but instead of looking for scoreboard values it looks for items in the players inventory
Now redo your sign and change the tag
then copy the command generated and paste it into a command block and power it to get your sign. Then place the sign given to you and place it where you would like your Interface to be. (Depending on where you put it change how far down the redstone block is placed.
And the setup is the same
Command Block 1
Once you click the sign it places a redstone block 3 blocks down or whatever you did it as, then below the redstone block place a command block.
This command block is Repeat, Unconditional And Always Active.
Command Block 2
In this command block we are defining the item and who can sell and also telling the player if they dont have the defined item.
Lets break down this command
This is defines the item you want sold
This defines if the player has clicked the sign, also tag=AuthBuyDiamond and that is the Tag you added in your sign make sure if you changed your tag name keep it the same.
This command block is Impulse, Unconditional And Needs Redstone.
Command Block 3
In this command we add funds to player
This command block is Chain, Unconditional And Always Active.
Command Block 4
In this command we clear the item from the players inventory
This command block is Chain, Unconditional And Always Active.
Command Block 5
In this command block we are playing a sound for a selling an item successful.
Please note the volume is controlled by the master volume.
This command block is Chain, Conditional And Always Active.
Command Block 6
This tells the player if their item sold successfully
This command block is Chain, Unconditional And Always Active.
Command Block 7
This command block removes the tag from the player
This command block is Chain, Unconditional And Always Active.
Thats the end of the tutorial i hope you found it useful and if you have any questions be sure to comment!
The scoreboard command is a very useful command when tracking certain criteria for example Deaths, Health or Levels but for this tutorial i'll be using the Dummy criteria.
/scoreboard objectives add <Objective Name> dummy <Display Name>
You can get a fancy Tellraw display name using this website here for this tutorial i will be using
["",{"text":"[ Money ]","bold":true,"color":"green"}]
Once you have your new objective we have to display it, There are many ways you can display your new objective Sidebar, List , Belowname.
/scoreboard objectives setdisplay <Your Choosen Display Method> Money
Once you display your Objective don't be alarmed when you see nothing happen you have to now add a value to a player this can be done using.
/scoreboard players add <Player> Money 100
Likewise you can remove Scores too using
/scoreboard players remove <Player> Money 100
Awesome! you now have the ground work for this tutorial! Now ill tell you how to integrate this into your shopping system
Shop Interface
Now lets add a Interface instead of using a button or lever ill be adding a clickable sign that will do 2 things setblock a couple blocks underneath the sign and Tag the person who clicks the sign. This website is extremely useful.
On this website Add text to your sign (Doesn't matter what you write)
Then scroll down til you see: Commands Minecraft runs when a player click on the sign:
The “/Setblock ~ ~-3 ~ minecraft:redstone_block replace” places a redstone block 3 blocks down; you can change how far down you would like to place the block; this command will be useful later.
The “/tag @s add AuthItem” gives the player who right clicks the sign a tag of your choice, I do Auth and then the item for example AuthDiamond, But you can call this tag anything you like.
Then copy the command generated and paste it into a command block and power it to get your sign. Then place the sign where-ever you would like your Interface to be. (Depending on where you put it change how far down the redstone block is placed.
There! That's all you need for the Sign now onto the command blocks.
Adding The Buy System
Now in this section it can get confusing so ill try and word it to make it is as understandable as possible.
There are 7 Command blocks that make up this system labeled here
Command Block 1:
Once you click the Sign it places a redstone block for mine it places it 3 blocks down then right below the redstone block place an Always Active, Repeating, Unconditional Command Block. With "/setblock ~ ~1 ~ air replace" This instantly removes the redstone block once it was placed.
/setblock ~ ~1 ~ air replace
Command Block 2:
In this command block we are defining the price and who can buy, and also telling the user if they don’t have enough funds.
/execute as @p if entity @p[scores={Money=..29},tag=AuthDiamond] unless entity @p[scores={Money=30..},tag=AuthDiamond] run tellraw @p ["",{"text":"You don't have the funds!","bold":true,"color":"red"}]
It could look confusing so lets break it down
As we can see in this command we use
@p[scores{Money=..29}]
This means if that player has $29 or lessAnd we use a similar looking command
@p[scores={Money=30..}]
This means if that player has $30 or more So $30 is our price and it will only work if the player has $30 and if it detects that the player has $29 for less it will say "You Don't The Funds!" (Also feel free to change the price)
We also see tag=AuthDiamond and that is the Tag you added in your sign make sure if you changed your tag name keep it the same.
And the command block is Impulse, Unconditional and Needs Redstone.
Command Block 3:
This command block gives the Player 1 diamond if the players Money is $30 or more and if the Player has the AuthDiamond tag
/give @p[scores={Money=30..},tag=AuthDiamond] minecraft:diamond 1
And the command block is Chain, Unconditional and Always Active.
Command Block 4:
This command block tells the Player "Thanks for your purchase!" while still checking if the player has $30 or more and if the player has the AuthDiamond tag.
/tellraw @p[scores={Money=30..},tag=AuthDiamond] ["",{"text":"Thanks for your purchase!","bold":true,"color":"green"}]
And the command block is Chain, Unconditional and Always Active
Command Block 5:
In this command block we are playing a sound for a successful purchase while still checking if the player has $30 or more and if the player has the AuthDiamond tag.
/playsound minecraft:entity.arrow.hit_player master @p[scores={Money=30..},tag=AuthDiamond] ~ ~ ~ 1
Also the volume is controlled by master volume.
This command block is Chain, Unconditional and Always Active
Command Block 6:
This command block will take away your funds while still checking if the player has $30 or more and if the player has the AuthDiamond tag.
/scoreboard players remove @p[scores={Money=30..},tag=AuthDiamond] Money 30
This command block is Chain, Unconditional and Always Active
Command Block 7
This command block removes the AuthDiamond tag.
/tag @a remove AuthDiamond
This command block is Chain, Unconditional And Always Active
Adding The Sell System
The sell system is pretty similar but instead of looking for scoreboard values it looks for items in the players inventory
Now redo your sign and change the tag
then copy the command generated and paste it into a command block and power it to get your sign. Then place the sign given to you and place it where you would like your Interface to be. (Depending on where you put it change how far down the redstone block is placed.
And the setup is the same
Command Block 1
Once you click the sign it places a redstone block 3 blocks down or whatever you did it as, then below the redstone block place a command block.
/setblock ~ ~1 ~ air replace
This command block is Repeat, Unconditional And Always Active.
Command Block 2
In this command block we are defining the item and who can sell and also telling the player if they dont have the defined item.
/execute as @p unless entity @s[nbt={Inventory:[{id:"minecraft:diamond"}]},tag=AuthSellDiamond] unless entity @p[nbt={Inventory:[{id:"minecraft:diamond",}]},tag=AuthSellDiamond] run tellraw @p[tag=AuthSellDiamond] ["",{"text":"You don't have that item!","bold":true,"color":"red"}]
Lets break down this command
@s[nbt={Inventory:[{id:"minecraft:diamond"}]}]
This is defines the item you want sold
@s[tag=AuthSellDiamond]
This defines if the player has clicked the sign, also tag=AuthBuyDiamond and that is the Tag you added in your sign make sure if you changed your tag name keep it the same.
This command block is Impulse, Unconditional And Needs Redstone.
Command Block 3
In this command we add funds to player
/scoreboard players add @p[nbt={Inventory:[{id:"minecraft:diamond",}]},tag=AuthSellDiamond] Money 30
This command block is Chain, Unconditional And Always Active.
Command Block 4
In this command we clear the item from the players inventory
/clear @p[tag=AuthSellDiamond] minecraft:diamond 1
This command block is Chain, Unconditional And Always Active.
Command Block 5
In this command block we are playing a sound for a selling an item successful.
/playsound minecraft:entity.arrow.hit_player master @p[tag=AuthSellDiamond] ~ ~ ~ 1
Please note the volume is controlled by the master volume.
This command block is Chain, Conditional And Always Active.
Command Block 6
This tells the player if their item sold successfully
/tellraw @p[tag=AuthSellDiamond] ["",{"text":"Sold For $30!","bold":true,"color":"green"}]
This command block is Chain, Unconditional And Always Active.
Command Block 7
This command block removes the tag from the player
/tag @a remove AuthSellDiamond
This command block is Chain, Unconditional And Always Active.
Thats the end of the tutorial i hope you found it useful and if you have any questions be sure to comment!
Credit | https://minecraft.tools/en/ , https://minecraftjson.com/ |
Tags |
tools/tracking
4560789
6
1-15-comprehensive-minecraft-shop-and-currency
Create an account or sign in to comment.