For instance, I want to create a scoreboard objective for Time Played on a server, and I want every player to have their score as the amount of seconds they are playing. I used a dummy objective, but when I tried to add a score of 0.05 to every player via a repeating command block (so after 20 ticks = 1 second, it would add 1 second), it didn't work (the integer can't be a fraction, apparently). Is there a way to get around this?
Edit: I figured out an alternative. Creative a scoreboard objective for time played, then set a repeating command block that will add a score of 1 to a fake player.
Then, put a chain command block (set on conditional) that will set the fake player's score back to 0, if its score has reached 20.
Then, put a final chain command block (conditional) that will add 1 point to the time played for all players.
This way, every time the fake player's score reaches 20, it resets and all players get 1 point (1 second), and it will essentially "count" the real players' playtime in seconds.
I hope this helps anyone that is looking for a way to make something like this work.
The commands:
Creating the objective:
scoreboard objectives add timeplayed_sec dummy
Repeating command block (unconditional):
scoreboard players add timer timeplayed_sec 1
Chain command block (conditional):
execute if score timer timeplayed_sec matches 20 run scoreboard players set timer timeplayed_sec 0
Basically just the title.
For instance, I want to create a scoreboard objective for Time Played on a server, and I want every player to have their score as the amount of seconds they are playing. I used a dummy objective, but when I tried to add a score of 0.05 to every player via a repeating command block (so after 20 ticks = 1 second, it would add 1 second), it didn't work (the integer can't be a fraction, apparently). Is there a way to get around this?
Edit: I figured out an alternative. Creative a scoreboard objective for time played, then set a repeating command block that will add a score of 1 to a fake player.
Then, put a chain command block (set on conditional) that will set the fake player's score back to 0, if its score has reached 20.
Then, put a final chain command block (conditional) that will add 1 point to the time played for all players.
This way, every time the fake player's score reaches 20, it resets and all players get 1 point (1 second), and it will essentially "count" the real players' playtime in seconds.
I hope this helps anyone that is looking for a way to make something like this work.
The commands:
Creating the objective:
Repeating command block (unconditional):
Chain command block (conditional):
Chain command block (conditional):