This was a very interesting challenge for me to work out. There are many parts to this problem, which are a lot harder to accomplish than one might think. There's identifying the player with the status effect, and identifying a set of random players who are not them (since /tp Unionhawk Unionhawk
is a valid result of /tp @p @r
, and does nothing).
But, finally, here is my setup, which works for a bounded number of players on a server. Some of its flaws include only allowing one game to be played on a given server, and using experience level to identify players. As such, /gamerule doMobLoot false
must be used, and /gamerule commandBlockOutput false
is strongly advised.
So there's quite a lot of things going on here, as you can see. But this is all accomplished using 4 commands and a hopper clock.
The Group 1 command blocks are there to detect when a player has the specified potion effect, remove it, and proceed to the matching Group 2 command block. I used /effect @p[c=n] 4 0
for that one, which removes the mining fatigue effect from player n on the server (going down the list of players on the server). When that command evaluates, the Group 2 command blocks give that player one level of experience using /xp 1L @p[c=n]
.
From there, the next time the hopper clock pulses, the "Group" 3 (you only need one) command block teleports a player with 1 level or more to a random player without any levels using /tp @p[lm=1] @r[l=0]
. When this command evaluates, the "Group" 4 command block clears the experience level of all players using /xp -9999L @a
.
I will test this when I get access to a desktop, but I belive tp @a[x=?,y=?,z=?,r=1] x y z
on repeat should work. It worked for me in 1.7, but I haven't tested this on 1.10 yet.
Best Answer
Command:
tp @a[x=171,y=14,z=169,distance=..0.5] 83 15 -177
How you can use this:
/give @s command_block
2. To avoid having your chat being over run by messages, set gamerule CommandBlockOutput to false.
/gamerule commandBlockOutput false
3. Go to the purple block and stand on top of it. Once you are standing on the block, hold shift + f3 to find your coordinates. These will be referred to as x1, y1, and z1.
(Optional) Type your coordinates into chat to help you remember them.
4. Now, go to the red block, and repeat step 3. These will be referred to as x2, y2, and z2.
5. Now, go to where you want the command block to be placed, and place it there.
6. Right-click your mouse on it, and change
Impulse
toRepeat
.7. Now change
Needs Redstone
toAlways Active
.8. Now type
tp @a[x=X1,y=Y1,z=Z1,distance=..0.5] X2 Y2 Z2
into the area that saysConsole Command
.9. Hit
Done
.