I am trying to make a server which supports multiple people. I want to make it so that when a player joins for the first time, they are assigned a scoreboard value under a dummy objective. I need this to be unique to each player. Say, when the first player joins he gets assigned the value of 1 under the objective of class. The second person to join would be assigned the value of 2, and so on and so forth. I am not sure how to do this, and any help would be appreciated. Thanks!
You can cause each new player to increment a fake player's score, and then give that new player the same score:
Prerequisites
Objective to track unique IDs:
/scoreboard objectives add ID dummy
Clock commands
The following must be run in numerical order on a clock:
1. Cause new players to increment a fake player's score by 1. That fake player will always hold the latest ID. The ID will be 1 for the very first new player, then 2 for the next new player, and so on.
You can cause each new player to increment a fake player's score, and then give that new player the same score:
Prerequisites
Objective to track unique IDs:
/scoreboard objectives add ID dummy
Clock commands
The following must be run in numerical order on a clock:
1. Cause new players to increment a fake player's score by 1. That fake player will always hold the latest ID. The ID will be 1 for the very first new player, then 2 for the next new player, and so on.
2. Set that new player's score equal to the fake player's new score.
/scoreboard players operation @a[tag=!processed,c=1] ID = #current ID
3. Then add the "processed" tag to the player so that they will not be considered new anymore.
/scoreboard players tag @a[tag=!processed,c=1] add processed
This will support multiple new players joining the game at the exact same time.
Thank you for the help! This is scoreboard stuff way over my head, but I have one question. How would I reset this "fake player" back to 0. As I left the first command running on a clock for a few seconds by mistake, and now every new player starts with an ID in the 600's.
Thank you for the help! This is scoreboard stuff way over my head, but I have one question. How would I reset this "fake player" back to 0. As I left the first command running on a clock for a few seconds by mistake, and now every new player starts with an ID in the 600's.
You can run the following command to set the fake player's score to a specific value (example being 0):
/scoreboard players set #current ID 0
However, you'll run into an issue as players were already given the "processed" tag, so you may need to manually fix their scores for whoever it affected (and then adjusting the "#current" score based on the last ID manually set).
You can run the following command to set the fake player's score to a specific value (example being 0):
/scoreboard players set #current ID 0
However, you'll run into an issue as players were already given the "processed" tag, so you may need to manually fix their scores for whoever it affected (and then adjusting the "#current" score based on the last ID manually set).
You are a lifesaver! I haven't worked with scoreboard in a while, and I had no idea any of this was possible. I think I have a basic understanding of it now. Thank you so much!
I am trying to make a server which supports multiple people. I want to make it so that when a player joins for the first time, they are assigned a scoreboard value under a dummy objective. I need this to be unique to each player. Say, when the first player joins he gets assigned the value of 1 under the objective of class. The second person to join would be assigned the value of 2, and so on and so forth. I am not sure how to do this, and any help would be appreciated. Thanks!
You can cause each new player to increment a fake player's score, and then give that new player the same score:
Prerequisites
Objective to track unique IDs:
Clock commands
The following must be run in numerical order on a clock:
1. Cause new players to increment a fake player's score by 1. That fake player will always hold the latest ID. The ID will be 1 for the very first new player, then 2 for the next new player, and so on.
2. Set that new player's score equal to the fake player's new score.
3. Then add the "processed" tag to the player so that they will not be considered new anymore.
This will support multiple new players joining the game at the exact same time.
Minecraft-things: http://skylinerw.com
More Minecraft-things: https://sourceblock.net
Guides for command-related features (eventually moving to Source Block): https://github.com/skylinerw/guides
I primarily hang out in the /r/MinecraftCommands discord, where there's a lot of people that help with commands: https://discord.gg/QAFXFtZ
Their corresponding subreddit: https://www.reddit.com/r/MinecraftCommands/
Thank you for the help! This is scoreboard stuff way over my head, but I have one question. How would I reset this "fake player" back to 0. As I left the first command running on a clock for a few seconds by mistake, and now every new player starts with an ID in the 600's.
You can run the following command to set the fake player's score to a specific value (example being 0):
However, you'll run into an issue as players were already given the "processed" tag, so you may need to manually fix their scores for whoever it affected (and then adjusting the "#current" score based on the last ID manually set).
Minecraft-things: http://skylinerw.com
More Minecraft-things: https://sourceblock.net
Guides for command-related features (eventually moving to Source Block): https://github.com/skylinerw/guides
I primarily hang out in the /r/MinecraftCommands discord, where there's a lot of people that help with commands: https://discord.gg/QAFXFtZ
Their corresponding subreddit: https://www.reddit.com/r/MinecraftCommands/
You are a lifesaver! I haven't worked with scoreboard in a while, and I had no idea any of this was possible. I think I have a basic understanding of it now. Thank you so much!