I’m making a spleef mini game in Minecraft pe/bedrock and I need to detect if there is ONLY ONE player left in the arena. Only one player and no more and no less.
How this works is the number after the “c” is the amount of max redstone strength through a comparator if 7 people are in the 20 block radius (toggle the number to the size of your area) if the number after c is 6 redstone goes 6. If it is 7 it will go 7. If it is 8 redstone goes 7. If you want a specific mode because a spectator can mess it up.
0 meaning survival m meaning mode
0 is survival mode
1 is creative mode
2 is adventure mode
3 is spectator mode
When the match starts, have the respawn point be outside the render distance, maybe 400-500 away. For this to work, there will have to be an outdent in one of the walls. This area in the arena is where the last person must go to to win. Have a command block whose range stops about 1-2 blocks from this outdent. Then, run the command “/testfor @e[type=player]”. Have a chain command block place a repeater that connects two redstone lines. Wire the output into an inverter circuit. Run this new redstone output into command blocks THAT ARE WITHIN RANGE OF THE ENTIRE ARENA. I warn you that this system has two flaws, one which has an unorthodox solution. Firstly, should all the players go into the “win zone”, the command block module will activate, resulting into a collective victory. The other problem occurs when the second to last player is killed, but the “win zone” is cut off by holes, therefore making it impossible to get to the win zone. To solve this, I suggest this strange solution. Be warned that this will change gameplay a bit. Each player is to have 5 scaffolding blocks, preferably something like dirt, at the beginning of the round. The “/replaceitem” command makes sure they can only have 5 dirt blocks at once. If the gamemode is adventure, add the “can_be_placed” tag. The blocks dirt can be placed on should be itself, snow and the material(s) your walls are made of. Also, remember to add the “can_destroy” tag to the shovel.
Most of my experience is to do with the java edition, however this still might work
Edit: I've been informed that scoreboards do not exist on the pocket edition, as such this solution will not work for that version. However I'll leave this answer for people using the Java edition
If you have a command block with a
/testfor for the area, you can use a
/stats command to put the result, aka how many players are left, into a scoreboard objective.
First make the scoreboard:
/scoreboard objectives add <score_name> dummy
<score_name> is whatever you want, just has to be the same everywhere
Then run this command once:
/scoreboard players set <name> <score_name> 0
This will make a fake player with name of
<name> to store the count of players.
Then run this command in the command block that's going to have the
/stats block ~ ~ ~ set QueryResult <name> <score_name>
Note: you can also look at the command block and tab-complete in the x, y and z location of the command block and run it from the chat, I'd recommend this way. (if pocket edition has tab-completion idk)
Lastly to check if the right amount of players are left use:
/scoreboard players test <name> <score_name> 1 1
Note: the first 1 is the min, the second is the max, so it could be used to check if a range of players are left, or whatever.
I don't know if this will actually help, but I'm hoping it will. Enjoy your custom spleef.