Minecraft Command to check for even player distribution in teams?

Cr
5

I'm currently building a mini-game in which players are divided into 2 teams. But I want the players to be divided equally between the teams, but everyone can still decide the team themselves under the conditions. I have been racking my brains for weeks and can hardly get a sensible solution. Does the community have any idea how I could implement this?

Hu

Large servers are already using this concept, so I would look to see which plugins they use, how they solved it, or search for and develop lobby minigames plugins that have already been developed on the Internet.

In principle it is quite simple from a logical point of view. First the players choose and are divided into 2 or more lists. Then the rest are assigned.

Each player accepts a property, is assigned a class or the like. You can set the condition that each class has no more than e.g. 3 players may belong by placing an if in the selection - if someone selects a full class, he will be rejected.
Now the timer is over and the rest, which still has NO class, must be assigned. The easiest way would be to simply fill them all up to 3 in sequence. Or you can add one player to each class in each loop until everyone is full.
If you want to do point 2 very precisely and optimally, a small database is probably necessary, from which you can read out the number of players in the groups so far, in order to calculate the optimal distribution. This may also work through a command block test who is nearby if you separate the pre-division of the teams.

I hope I could help you. I also think the StackOverflow page could help you in some respects. But beware, the people there are very intelligent and expect intelligent, well thought-out questions from you!

Cr

I specifically ask for Minecraft Commands, because I want to run the mini-game behind it completely without plugins.

Hu

Then follow the procedure as programmers would do it. There's no Minecraft command for this. You have to be creative.

Minecraft commands are not designed to be used to create mini-games. You will encounter many, far greater problems than what you have now. It would be a shame if you waste all your energy, motivation and enthusiasm and are only dissatisfied in the end because you have resisted game extensions.

Cr

The rest can be implemented really well. The only thing that gives me a headache is the even distribution of the team.

Hu

Then do it with the spatial division and testfor number of players in a room order or with pressure plates where the players have to stand, that would be much easier.