You can cause all players on a team to add 1 to a scoreboard objective. The result is the score being equal to the number of online players in that team. For example, adding 1 to the score of fake player named "#NUM":
If he wants perfect teams, the deltaNumb should be 0, and if he wants near perfect teams, the deltaNumb can range from -1 to 1. If the number ends up being negative, blue is larger. If the number ends up being positive, red is larger. He can then eject a random player, or simply display a message saying which team has more players and that the game can't start until it is equal.
Because the deltaNumb is a fake player, we will have to use the scoreboard players test function. Alternatively, you could set it up to be executable off of an armorstand.
Rollback Post to RevisionRollBack
I have a small YouTube channel and would greatly appreciate it if you were to check me out!!
My bad, missed the team balance part. As an alternative method, you could have one team add to a score and then have the other team reduce from the score:
If #NUM is 0, the teams are equal. If it's negative, there are more players on TEAM2 than TEAM1, and if positive there are more TEAM1 players, same as your operation method. Of course, if there's more than 2 teams, then this won't work out.
I am making a map and I want to test how many players are on a team so I can make the teams even can someone please tell me
You can cause all players on a team to add 1 to a scoreboard objective. The result is the score being equal to the number of online players in that team. For example, adding 1 to the score of fake player named "#NUM":
You must use /scoreboard's "test" function to detect a fake player's score. The following checks if there's at least 10 players on the team: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/
The only problem with this is that you don't know how many players you want on a team, at least for Diamond Shark's case.
So after the initial count which is:
We will then:
If he wants perfect teams, the deltaNumb should be 0, and if he wants near perfect teams, the deltaNumb can range from -1 to 1. If the number ends up being negative, blue is larger. If the number ends up being positive, red is larger. He can then eject a random player, or simply display a message saying which team has more players and that the game can't start until it is equal.
Because the deltaNumb is a fake player, we will have to use the scoreboard players test function. Alternatively, you could set it up to be executable off of an armorstand.
I have a small YouTube channel and would greatly appreciate it if you were to check me out!!
My bad, missed the team balance part. As an alternative method, you could have one team add to a score and then have the other team reduce from the score:
If #NUM is 0, the teams are equal. If it's negative, there are more players on TEAM2 than TEAM1, and if positive there are more TEAM1 players, same as your operation method. Of course, if there's more than 2 teams, then this won't work out.
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/