Looking for a way to clear an area of all but one player, using only command blocks and no comparators.
I tried fiddling around with the c=C in target selectors, but didn't get far. c=!1 doesn't seem to work. Can anyone think of a way to accomplish the above? If there are 5 people in an area in a coordinate box, the command blocks should teleport 4 of them elsewhere and leave only 1.
you add an scoreboard objective: /scoreboard objectives add tpscore dummy tpscore
you give score to random player: /scoreboard players add @r tpscore 1
than you tp: /tp @a[score_tpscore_min=0,score_tpscore=0] x y z
than to reset all scores of all players: /scoreboard players reset @a
those 'll teleport all players who have a score = 0 the player with score 1 'll stay
I hope it works I couldn't test because I can't have multiplayer right now XD
note: it 'll pick a random player because of the @r selector
When wanting to do something like this, where you need a boolean (true/false) and not an integer, you should use scoreboard tags and not scoreboard objectives.
/scoreboard players tag @r add tpStay
/tp @a[tag=!tpStay] X Y Z
/scoreboard players tag @a[tag=tpStay] remove tpStay
Looking for a way to clear an area of all but one player, using only command blocks and no comparators.
I tried fiddling around with the c=C in target selectors, but didn't get far. c=!1 doesn't seem to work. Can anyone think of a way to accomplish the above? If there are 5 people in an area in a coordinate box, the command blocks should teleport 4 of them elsewhere and leave only 1.
Thanks for any help
When wanting to do something like this, where you need a boolean (true/false) and not an integer, you should use scoreboard tags and not scoreboard objectives.
Used the tags, seems to work fine, thanks guys