I'm doing a SkyWar Game using just commandblocks and I need help to check when there's just one player left (Winner), the others when they die they're kicked from the server, so I need to check when there's just one left. I've searched a lot but couldn't find any solution
You can detect the number of players with one command block and then use another command block to directly check the success of the other one.
1. Find if there are 0, 1, or 2 players. The count is restricted to 2 just to reduce the amount of processing that occurs (as /testfor is processed multiple times, equal to the number of targets obtained). Since you only need to know if there's 1 player, then a result of 2 simply means "more than 1 player".
/testfor @a[c=2]
2. Conditional. Check if the repeating block's "SuccessCount" is 1, which means that there was only 1 player found.
/testforblock X Y Z minecraft:repeating_command_block -1 {SuccessCount:1}
3. Conditional. Command to run as a result of success.
I'm doing a SkyWar Game using just commandblocks and I need help to check when there's just one player left (Winner), the others when they die they're kicked from the server, so I need to check when there's just one left. I've searched a lot but couldn't find any solution
You can detect the number of players with one command block and then use another command block to directly check the success of the other one.
1. Find if there are 0, 1, or 2 players. The count is restricted to 2 just to reduce the amount of processing that occurs (as /testfor is processed multiple times, equal to the number of targets obtained). Since you only need to know if there's 1 player, then a result of 2 simply means "more than 1 player".
2. Conditional. Check if the repeating block's "SuccessCount" is 1, which means that there was only 1 player found.
3. Conditional. Command to run as a result of success.
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/
sorry. but why not just do testfor @a and use a comparator? if there is only 1 player you only get 1 lit redstone
If Someone Is Helpful, Please Remember To Thank Them By Hitting The Green Up Arrow
That's just another way to do it, except that causes block updates (which the new command blocks do not cause).
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/
ill have to learn more about those then
If Someone Is Helpful, Please Remember To Thank Them By Hitting The Green Up Arrow