I am trying to set up a multiplayer vanilla 1.8 server for my kids. I want it to be survival but to give them a bit of a leg up, so thought I could have command blocks that could give them a basic kit and another that gave them some food. I can figure out how to give them the items but I would like there to be some limit on how often an individual player could get it, for example only once per death, or only once every 15 minutes. Can someone give me some tips about how to get those restrictions working? I figure it would use the scoreboard to track things but I have never used the scoreboard before. Thanks.
I personally, would use modulus instead of testing for a certain number, adding to a different variable, and finally resetting the old variable. With modulus, it will automatically set it back to 0 when it reaches the number.
/execute @a[score_minutes=0,score_seconds=0,score_ticks=0] ~ ~ ~ clone a chest kit from nearby near the player here
With this method everything is fully customizable with scoreboards, no editing command blocks. You will need to initialize all the objectives as dummy and give @a some default values:
/scoreboard players set @a tickRate 20
/scoreboard players set @a secRate 60
/scoreboard players set @a kitRate 15
Now lets say 15 minutes is too frequent, you want it to only give the kit every half hour? Just type this into chat: /scoreboard players set @a kitRate 30
Nope. Each players time is individual to them and it only counts while they are online. So if you play for 10 minutes and leave, when you come back you will receive a kit in 5 minutes.
Oh and for added fun, we can make a gamerule for how many minutes of play time before a player receives a kit:
/scoreboard players add @p kitRate 0
/gamerule kitDropRate
Now stand on top of the second command block and type this into chat:
/stats block ~ ~-1 ~ set QueryResult @a kitRate
Now to set the time between kits you can simply type: /gamerule kitDropRate 22
And now every 22 minutes of playing you will get the kit.
Edit: I don't know why I didn't just do it like this from the beginning:
I'm not sure what you mean. How should the fill clock be connected to the command blocks, and how should they be ordered?
Thanks for your help, by the way. I am learning a lot.
In the same manor as before, in the order I provided. Remember order of execution is least to greatest along the x,y,z. So choose either up or positive along the x or z and put the command blocks in a line.
Edit: If you wanted to use the gamerule, then you can just put those two commands anywhere on the fill clock and the order of them doesn't matter. Just be sure to stand on top the /gamerule command block and type the /stats command I provided.
All players get their minutes variable set to the modulus of kitRate and itself?
This one I'm not s sure about.
So then I can have a button hooked up to a few command blocks that will give the player some items.
Well we are setting tickRate to 1200 in this case, because there are 20 ticks in a second and 60 seconds in a minute, 1200=20*60. So when it hits 1200 it will be set to 0.
I'm unsure if everyone understands the modulus operator, so I'll give a quick explanation of what it does. Modulus is the remainder after dividing. So 5%2=1, because 5/2=2.5, so the remainder*divisor=modulus. 0.5*2=1. In this use here we are doing every number between 1 and 1200 mod 1200. 1%1200=1, 2%1200=2, 1199%1200=1199, 1200%1200=0.
/scoreboard players add @a ticks 1
So the first thing that happens is ticks will be increased by 1. Since we are adding 1, this circuit never starts at 0.
We set the players tick count to the result of modulusing that number by 1200. Until this circuit has executed 1200 times, this command will not actually appear to do anything.
The next command looks for any players that have their ticks set to 0. If it equals 0, then we know that the last command set their ticks from 1200 to 0. So we know a minute has passed and we add 1 to the players minutes score.
This command does the same operation as the second command but with different variables and values. This is testing for when a players minutes have reached the needed amount of time to receive a kit. If kitRate is 15, then the players tickRate has hit 1200 and set back to zero 15 times. The tick that minutes gets increased to 15, their ticks is going to be 0 and minutes will now be set to 0.
/execute @a[score_minutes=0,score_ticks=0] ~ ~ ~ clone a chest kit from nearby near the player here
Now we simply find a player with minutes and ticks set to 0 and give them the kit. The only time minutes and ticks will both be 0 is right when the player hits the 15 minute mark, because ticks starts at 1 and when it gets the chance to be 0 again minutes is now 1.
Edit: Oops, realized on the add 1 to minutes command, I was testing for the wrong player and it wouldn't have ever worked. It needs to be looking for a player with score_ticks=0, not score_tickRate=0.
Now how could I change this so that brand new players can get a kit right away. Keep a count of number of times the kit has been given and if it hs never been given then they can get one right away??
/execute @a[score_minutes=0,score_kits=0] ~ ~ ~ command to give @p the kit
/scoreboard players set @a[score_minutes=0] kits 1
/scoreboard players set @a[score_minutes_min=1] kits 0
This should do the trick for ya. Basically the same as before, but the scoreboard minutes is of type stat.playOneMinute so we don't have to keep count of that by hand anymore. And new players will receive one right away.
Edit: I'm not sure if this is a bug or just something wrong in my world, but I just setup a stat.playOneMinute objective and it seemed to count up every tick.. Not every 1200 ticks. If this happens, just add a second %= line converting it from ticks to minutes, minutes %= 1200 %= kitRate.
Awesome. Should all of this go in the spawn chunks so that it works all the time when players logged in and not just when players have that chunk loaded? Or do command blocks and commands work all of the time?
So these set up the variables that will be used. Do they need to be in command blocks? It seems like they should be able to be entered at the command line once in the world when I am setting things up? They don't seem to reference players.
These 2 commands seem to initialise each players variables. When a new player joins they will not have these variables set so these do need to be on a clock so that new joining players will have these initialsed for them?
minutes = minutes mod kitRate
which is then the same as
minutes = minutes mod kitDropRate
Why did we need that extra level of indirection?
Minutes is set up as a game stat, so it should automatically get incremented each minute of game time? We just play around with it because we only care about incremental times, not total time?
If later for another purpose we wanted have total minutes we could do something like
myMinutes = minutes
myMinutes = myMinutes mod kitRate
and then use score-myMinutes below??
Now I get this bit, but want to just clarify...
/execute @a[score_minutes=0,score_kits=0] ~ ~ ~ command to give @p the kit
/scoreboard players set @a[score_minutes=0] kits 1
/scoreboard players set @a[score_minutes_min=1] kits 0
For the command to give a player a kit, I had initially seen it done by having some command blocks chained together with repeaters, each one giving an item, eg stone sword, stone pick, so on. I have seen it mentioned in this thread to clone a chest that contains the kit, which I guess is a single command. I just liked the idea of giving the items directly to the player. Comments?
Thanks for all of the great help. I am just getting a bit confused as other better ways suggested, and mixed up as I have done some commands directly and others with a fill clock and now am a bit mixed up which need the fill clock and which don't and which work because I have already typed something in before during experimenting. Just wanting to get it all straight in my mind so I can tinker with it all later.
I am trying to set up a multiplayer vanilla 1.8 server for my kids. I want it to be survival but to give them a bit of a leg up, so thought I could have command blocks that could give them a basic kit and another that gave them some food. I can figure out how to give them the items but I would like there to be some limit on how often an individual player could get it, for example only once per death, or only once every 15 minutes. Can someone give me some tips about how to get those restrictions working? I figure it would use the scoreboard to track things but I have never used the scoreboard before. Thanks.
Okay, the way I do this is I hook up a fill clock, and attach the following commands:
"scoreboard objectives add Ticks dummy"
"scoreboard objectives add Seconds dummy"
"scoreboard objectives add Minutes dummy"
"scoreboard objectives add KitUnlock dummy"
"scoreboard players add @a Ticks 1"
"scoreboard players add @a[score_Ticks_min=20] Seconds 1"
"scoreboard players set @a[score_Ticks_min=20] Ticks 0"
"scoreboard players add @a[score_Seconds_min=60] Minutes 1"
"scoreboard players set @a[score_Seconds_min=60] Seconds 0"
"scoreboard players set @a[score_Minutes_min=15] KitUnlock 1"
"scoreboard players set @a[score_Minutes_min=15] Minutes 0"
So when KitUnlock is 1, you can get the kit. This can be done with the following commands when triggered:
"give @a[score_KitUnlock_min=1] (Whatever item you want)"
Repeat this with all the items you want to give to the player.
"scoreboard players set @a[score_KitUnlock_min=1] KitUnlock 0"
Please check out my PvP map based around explosions and fire, FireFight!
Sometimes, I wonder why they call mapmakers mapmakers and not cartographers.
Dragons n' Stuff
Please click!
Thanks!
Would you use a hoper clock with just a few items items as a fill clock?
No, a fill clock is different. It consists of two commandblocks,one at the bottom, and one two blocks above it, with the commands:
Bottom one: "/fill ~20 ~1 ~ ~ ~1 ~ stone"
Top one: "/fill ~20 ~-1 ~ ~ ~-1 ~ redstone_block"
Please check out my PvP map based around explosions and fire, FireFight!
Sometimes, I wonder why they call mapmakers mapmakers and not cartographers.
Dragons n' Stuff
Please click!
So is this how you set it up? Fill clock on right, then line of command blocks.
Move the cmd blocks on the right over to the end of the left. Just to make sure they trigger in the right order. Otherwise, the fill clock is good.
Please check out my PvP map based around explosions and fire, FireFight!
Sometimes, I wonder why they call mapmakers mapmakers and not cartographers.
Dragons n' Stuff
Please click!
I personally, would use modulus instead of testing for a certain number, adding to a different variable, and finally resetting the old variable. With modulus, it will automatically set it back to 0 when it reaches the number.
/scoreboard players add @a ticks 1
/scoreboard players operation @a ticks %= @p[score_tickRate_min=0] tickRate
/scoreboard players add @a[score_ticks=0] seconds 1
/scoreboard players operation @a seconds %= @p[score_secRate_min=0] secRate
/scoreboard players add @a[score_seconds=0] minutes 1
/scoreboard players operation @a minutes %= @p[score_kitRate_min=0] kitRate
/execute @a[score_minutes=0,score_seconds=0,score_ticks=0] ~ ~ ~ clone a chest kit from nearby near the player here
With this method everything is fully customizable with scoreboards, no editing command blocks. You will need to initialize all the objectives as dummy and give @a some default values:
/scoreboard players set @a tickRate 20
/scoreboard players set @a secRate 60
/scoreboard players set @a kitRate 15
Now lets say 15 minutes is too frequent, you want it to only give the kit every half hour? Just type this into chat: /scoreboard players set @a kitRate 30
I had no idea about that. Thanks!
Will it do that with offline players though?
Please check out my PvP map based around explosions and fire, FireFight!
Sometimes, I wonder why they call mapmakers mapmakers and not cartographers.
Dragons n' Stuff
Please click!
Nope. Each players time is individual to them and it only counts while they are online. So if you play for 10 minutes and leave, when you come back you will receive a kit in 5 minutes.
Oh and for added fun, we can make a gamerule for how many minutes of play time before a player receives a kit:
/scoreboard players add @p kitRate 0
/gamerule kitDropRate
Now stand on top of the second command block and type this into chat:
/stats block ~ ~-1 ~ set QueryResult @a kitRate
Now to set the time between kits you can simply type: /gamerule kitDropRate 22
And now every 22 minutes of playing you will get the kit.
Edit: I don't know why I didn't just do it like this from the beginning:
/scoreboard players add @a ticks 1
/scoreboard players operation @a ticks %= @p[score_tickRate_min=0] tickRate
/scoreboard players add @a[score_tickRate=0] minutes 1
/scoreboard players operation @a minutes %= @p[score_kitRate_min=0] kitRate
/execute @a[score_minutes=0,score_ticks=0] ~ ~ ~ clone a chest kit from nearby near the player here
And type: /scoreboard players set @a tickRate 1200
1200 ticks is one minute.
I'm not sure what you mean. How should the fill clock be connected to the command blocks, and how should they be ordered?
Thanks for your help, by the way. I am learning a lot.
In the same manor as before, in the order I provided. Remember order of execution is least to greatest along the x,y,z. So choose either up or positive along the x or z and put the command blocks in a line.
Edit: If you wanted to use the gamerule, then you can just put those two commands anywhere on the fill clock and the order of them doesn't matter. Just be sure to stand on top the /gamerule command block and type the /stats command I provided.
Wow, lots here for me to process and think about!! Thanks guys, will be checking it out and playing with it over the weekend.
Oh I just noticed a slight typo in my previous post, to make the gamerule work, you need the following commands running on a clock:
/scoreboard players add @a kitRate 0
/gamerule kitDropRate
I accidentally typed @p before.
Let me check I understand what is happening.
/scoreboard players add @a ticks 1
Each tick every player currently online will have their ticks variable incremented by 1
i.e. ticks++
/scoreboard players operation @a ticks %= @p[score_tickRate_min=0] tickRate
The ticks variable is set to the modulus of the tick rate (20), so when it gets to 20 it will be set back to 0
/scoreboard players add @a[score_tickRate=0] minutes 1
Players whose tickRate score is 0 get 1 added to their minutes variable
i.e. if tickRate=0 then minutes++
/scoreboard players operation @a minutes %= @p[score_kitRate_min=0] kitRate
All players get their minutes variable set to the modulus of kitRate and itself?
This one I'm not s sure about.
So then I can have a button hooked up to a few command blocks that will give the player some items.
Well we are setting tickRate to 1200 in this case, because there are 20 ticks in a second and 60 seconds in a minute, 1200=20*60. So when it hits 1200 it will be set to 0.
I'm unsure if everyone understands the modulus operator, so I'll give a quick explanation of what it does. Modulus is the remainder after dividing. So 5%2=1, because 5/2=2.5, so the remainder*divisor=modulus. 0.5*2=1. In this use here we are doing every number between 1 and 1200 mod 1200. 1%1200=1, 2%1200=2, 1199%1200=1199, 1200%1200=0.
/scoreboard players add @a ticks 1
So the first thing that happens is ticks will be increased by 1. Since we are adding 1, this circuit never starts at 0.
/scoreboard players operation @a ticks %= @p[score_tickRate_min=0] tickRate
We set the players tick count to the result of modulusing that number by 1200. Until this circuit has executed 1200 times, this command will not actually appear to do anything.
/scoreboard players add @a[score_ticks=0] minutes 1
The next command looks for any players that have their ticks set to 0. If it equals 0, then we know that the last command set their ticks from 1200 to 0. So we know a minute has passed and we add 1 to the players minutes score.
/scoreboard players operation @a minutes %= @p[score_kitRate_min=0] kitRate
This command does the same operation as the second command but with different variables and values. This is testing for when a players minutes have reached the needed amount of time to receive a kit. If kitRate is 15, then the players tickRate has hit 1200 and set back to zero 15 times. The tick that minutes gets increased to 15, their ticks is going to be 0 and minutes will now be set to 0.
/execute @a[score_minutes=0,score_ticks=0] ~ ~ ~ clone a chest kit from nearby near the player here
Now we simply find a player with minutes and ticks set to 0 and give them the kit. The only time minutes and ticks will both be 0 is right when the player hits the 15 minute mark, because ticks starts at 1 and when it gets the chance to be 0 again minutes is now 1.
Edit: Oops, realized on the add 1 to minutes command, I was testing for the wrong player and it wouldn't have ever worked. It needs to be looking for a player with score_ticks=0, not score_tickRate=0.
Great explanation - thanks!!
Now how could I change this so that brand new players can get a kit right away. Keep a count of number of times the kit has been given and if it hs never been given then they can get one right away??
/scoreboard objectives add minutes stat.playOneMinute
/scoreboard objectives add kitRate dummy
/scoreboard objectives add kits dummy
/gamerule kitDropRate 15
/scoreboard players add @a kitRate 0
/scoreboard players add @a kits 0
/gamerule kitDropRate
Stand on top the above command and type: /stats block ~ ~-1 ~ set QueryResult @a kitRate
/scoreboard players operation @a minutes %= @p kitRate
/execute @a[score_minutes=0,score_kits=0] ~ ~ ~ command to give @p the kit
/scoreboard players set @a[score_minutes=0] kits 1
/scoreboard players set @a[score_minutes_min=1] kits 0
This should do the trick for ya. Basically the same as before, but the scoreboard minutes is of type stat.playOneMinute so we don't have to keep count of that by hand anymore. And new players will receive one right away.
Edit: I'm not sure if this is a bug or just something wrong in my world, but I just setup a stat.playOneMinute objective and it seemed to count up every tick.. Not every 1200 ticks. If this happens, just add a second %= line converting it from ticks to minutes, minutes %= 1200 %= kitRate.
Awesome. Should all of this go in the spawn chunks so that it works all the time when players logged in and not just when players have that chunk loaded? Or do command blocks and commands work all of the time?
It does indeed need to be in the spawn chunk.
So these set up the variables that will be used. Do they need to be in command blocks? It seems like they should be able to be entered at the command line once in the world when I am setting things up? They don't seem to reference players.
/scoreboard objectives add minutes stat.playOneMinute
/scoreboard objectives add kitRate dummy
/scoreboard objectives add kits dummy
/gamerule kitDropRate 15
These 2 commands seem to initialise each players variables. When a new player joins they will not have these variables set so these do need to be on a clock so that new joining players will have these initialsed for them?
/scoreboard players add @a kitRate 0
/scoreboard players add @a kits 0
/gamerule kitDropRate
Stand on top the above command and type: /stats block ~ ~-1 ~ set QueryResult @a kitRate
So this sets kitRate to be the same as kitDropRate?
Why do we need to query this, why can't we just use kitDropRate?
We only need to do this once?
/scoreboard players operation @a minutes %= @p kitRate
minutes = minutes mod kitRate
which is then the same as
minutes = minutes mod kitDropRate
Why did we need that extra level of indirection?
Minutes is set up as a game stat, so it should automatically get incremented each minute of game time? We just play around with it because we only care about incremental times, not total time?
If later for another purpose we wanted have total minutes we could do something like
myMinutes = minutes
myMinutes = myMinutes mod kitRate
and then use score-myMinutes below??
Now I get this bit, but want to just clarify...
/execute @a[score_minutes=0,score_kits=0] ~ ~ ~ command to give @p the kit
/scoreboard players set @a[score_minutes=0] kits 1
/scoreboard players set @a[score_minutes_min=1] kits 0
For the command to give a player a kit, I had initially seen it done by having some command blocks chained together with repeaters, each one giving an item, eg stone sword, stone pick, so on. I have seen it mentioned in this thread to clone a chest that contains the kit, which I guess is a single command. I just liked the idea of giving the items directly to the player. Comments?
Thanks for all of the great help. I am just getting a bit confused as other better ways suggested, and mixed up as I have done some commands directly and others with a fill clock and now am a bit mixed up which need the fill clock and which don't and which work because I have already typed something in before during experimenting. Just wanting to get it all straight in my mind so I can tinker with it all later.