How do I testfor a certain amount of players in a certain radius?
So I am making a Spleef game on my server and I need to testfor 12 players within about 35 blocks from the command blocks.
I tried /testfor @a[r=35]
leading into a /tp
command to teleport the players into the Spleef arena. What I don't have is to make it only teleport 12 players and not any more or less. So if you can help me with this I'd appreciate it.
Solution 1:
There is the count target selector argument.
/tp @p[x=<X>,y=<Y>,z=<Z>,r=<Radius>,c=<Count>] x y z
To detect if there is 12 players or more, there are 2 main ways to do it. One is simply with a comparator leading from a /testfor @a[x=<X>,y=<Y>,z=<Z>,r=<Radius>]
, which will emmit a redstone signal strength equal to the amount of players in that area and you can run a redstone wire to activate the teleport command, or do it with a scoreboard counter.