I am making a Battle Royale-type map in Minecraft 1.17, and trying to detect when there is only one person alive (in adventure mode) left.
Currently, I have commands to put people in spectator mode on death, and to set their score of "Alive" (z scoreboard objective) to 0 when they die. I have searched for hours, but all the solutions either don't apply to me, or use
/testfor instead of the execute command.
I would love to accomplish this using scoreboard objectives or teams (preferably scores) by detecting when there is only one player with an Alive score of one, or only one player on the Alive team. There is not a set number of people who will be playing this at any given time, and there is also a "Duos" mode if anyone wants to tackle that as well.
Also, I really do not want to write (another) datapack to do this and want to use only command blocks. Sorry if this limits some of you. If there is a (really easy) way to do this with a datapack functions and you can almost do it for me, I would accept that, but I am trying to steer clear of it.
Basically, to recap, I need to detect when someone "wins". This means when there is only one player left in adventure mode. (Or one team, if you're going to help me with that too. That would be amazing.)
I now have a fake player named "Players" for the scoreboard objective "Alive", and it displays the number of people in adventure mode in the sidebar using the command:
/execute store result score Players Alive if entity @e[type=minecraft:player,gamemode=adventure] in a repeating command block. Currently, that command block has a redstone output when there is at least one player in adventure mode. Changing this to be at most would be helpful. Anyone know how to do that?
I now have a way to detect when ONE person wins, (just changed adventure to
!adventure in code above (1st edit)) but need a way to detect when someone wins for duos mode. Sooo.... detect when a team is out (all their members are in spectator, or when 2 players are in spectator (!adventure) on that team), and detect when there is only one team not out. So. Solved first problem, need to fix duos mode.