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.
depending on the shape of your arena (square or circle), you can restrict a command to run only if entity
is within a certain range. i usually use, also, execute as @a at @s
, as it quite literally targets (as) everyone (@a) as if (at) they were the individual (@s).
in the instance of a cuboid (square/rectangular area), you'd want to use the x
, y
, z
, dx
, dy
, and dz
arguments (or settings you need to specify) to choose the area you want to limit it to;
x
is the X coordinate of your first corner.
y
is the Y coordinate.
z
is the Z.
dx
is the distance on the X axis to the opposite corner.
dy
is the distance on Y.
dz
is the distance on Z.
so, for an example, if i want to make a player say "hi" while in a 5x5x5 cube area, assuming the center is x0 y3 z0;
execute as @a at @s if entity @s[x=2,y=1,z=2,dx=-4,dy=4,dz=-4] run say hi
this would make it so if someone is in the area between the block at x2 y1 z2 and x-2 y5 z-2, it will run "say hi" as if that person ran the command itself.
Best Answer
In order to do this, you'll need to invert the check and the arguments.
Your old test: If there are any players in the radius, run the command.
Required new test: If there are any players outside the radius, do not run the command, otherwise run it.
Create a scoreboard objective to store the number of players outside the radius.
Create an always active repeating command chain of 4 blocks. Inside, place the following commands:
Reset the number of players outside the required range.
Tell everyone outside the range to add 1 to this value.
Set a redstone block to a nearby location.
Replace the
?
s with the coordinates of a convenient location nearby.Create an impulse command chain of 2 blocks. Place the starting block next to the location you specified in the last command. Place these commands inside:
Test for zero players outside the range.
CONDITIONAL: Run the command.