How can I kill or teleport everyone in a 20 block radius except for me and my friend. Our usernames are bob8898
and coach0512
. I was thinking that /kill {radius 20, type=!bob8898, type=!coach0512}
might work. Is this possible?
5 Answers
If you'd like to be excluded from a global selector, simply use a scoreboard to exempt yourselves.
This is due to the way entity selectors work, which does not allow you to specify specific players.
/scoreboard objectives add noKill dummy noKill
Now, tag yourselves for not killing, and run this in a 20Hz redstone clock, in the order it is provided:
/scoreboard players set @e noKill 0
/scoreboard players set [Your username] noKill 1
<Repeat for as many players>
/kill @e[score_noKill=0,score_noKill_min=0,r=100]
This way, you're marking everybody to be killed, exempting yourselves (by not making your score 0 and setting it 0 or nothing) then killing those who hasn't been exempted yet.
You can add more to the exemption list by adding a block with the following command before the last and after the first command blocks:
/scoreboard players set <Selectors and modifiers> noKill 1
Note: I may have gotten the syntax a bit wrong.
-
Although, I'm pretty sure inverting the
name
modifier with an!
on selectors will target all except the specific player, but I'm not too sure about specifying multiple players in the command. Commented Aug 31, 2015 at 23:02 -
Your method kills everything but Player 1, then it kills everything but Player 2, and the problem with that: Both players get killed anyhow, just not at the same time (presuming there's a delay between both commands). | Whenever you run commands, think of it as instructions. If they can be run with a 10 second delay between them, then it should work. Commented Aug 31, 2015 at 23:09
-
Then is it possible to make sure that nobody can edit the scoreboard?– Bob8898Commented Aug 31, 2015 at 23:34
-
It's as easy as: Be "not op'd"... Besides, since it's run on a clock, edits would only last for less than a tick before being reverted back to the values specified by the rules. Commented Aug 31, 2015 at 23:38
-
1
@Bob8898 If you want it to be a certain room only you can access put a command block on with a loop (Hopper Clock, Comparator Clock, etc)
/tp @e[r=(Enter Radius Here), type=!(Username)] (X Coordinate) (Y Coordinate) (Z Coordinate)
In 1.9 you can put the Always active function on and enter this command. If you want more players just repeat the Type variable.
Invert the name selector twice, using both your usernames. @a[name=!playerone,name=!playertwo]
means not playerone or playertwo.
/kill {radius 20, type=!bob8898, type=!coach0512} is very close, but this is how you do it:
/kill @e[r=20, type=!Player]
This will kill everything but players.
To do this if you are on a server with more than 2 people, we will use teams. this is a slightly easier way to do it than using scoreboard variables.
/scoreboard teams add noTeleport noTeleport
/scoreboard teams join noTeleport bob8898 coach0512
/kill @e[r=20, team=!noTeleport]
-
Can you test your second command? I'm almost positive the type tag does not allow player names. Commented Sep 1, 2015 at 2:09
-
Plus, the existence of 2 players guarantees it is multiplayer. Commented Sep 1, 2015 at 2:09
-
-
-
It is going to be on a server. I want it so that nobody, even other ops, cannot access a certain room.– Bob8898Commented Sep 3, 2015 at 23:54
radius 20
should also be changed tor=20