so im trying to create a prison escape server and i want to do all of it with command blocks and it has come along
i have 2 team Guards and Prisoners and im displaying how much players are in each team if one teams player count drops to 0 than the other wins but ive been thinking how do i know if someone leaves (disconnects) from the server because if i wont than there will still be 1 player in the team and if thats the last one the round will never end. I didnt find anything related to what i want to do so thats why i am posting this.
then it will automatically store the data that a player left the game and how many times they leave, but in this scenario, I don't believe that you actually want to track when a player leaves the game, rather than just if all players on a specific team aren't there. Is that right? If so, what you should do instead is
/execute if entity @a[team=Guards] unless entity @a[team=Prisoners]
/execute if entity @a[team=Prisoners] unless entity @a[team=Guards]
You can either add a comparator coming from each command block, or add "run <command>" with chain command blocks coming from the first one that each execute their own command. With this setup, it runs 2 tests at once, one for if there are no prisoners online, and one for if there are no guards online. I will mention that with this setup, if the players aren't put on separate teams at the exact same time, then it will execute the command to end the game. To prevent this, add an x=insert x coordinate of the center of the prison,y=insert y coordinate of the center of the prison,z=insert z coordinate of the center of the prison,distance=..100 or however big the prison is in each direction from the center of the prison.
Then all you have to do to make it work is teleport all the players in at the same time, or at least one prisoner and one guard at the same time before anyone else, and also make sure the waiting lobby, if there is one, isn't within a 100 block radius of the center of the prison. You could also do dx=,dy=,dz= for a more specific rectangular area, and therefore wouldn't have to worry about the waiting lobby being to close to the prison. Either way works.
Sorry if that sounded a little too complex, but I hope you figure it out eventually! Hope this helps!