Take the 2-minute tour ×
Arqade is a question and answer site for passionate videogamers on all platforms. It's 100% free, no registration required.

I want to make a teleport command with command blocks that allows only people with certain names to teleport. So basicly its an admin only button and if your name isnt on one of the command blocks you cant teleport, it would also check if the player was in a radius of two blocks. What I have tried is /tp <player name>[r=2] <coords here> and /tp @p[name=<player name>,r=2] <coords here> and neither have worked. Is this possible?

edit: The problem I'm having after further experimenting with the same code is when I use the <player name> to teleport it grabs the right person but it teleports them from anywhere no matter the person who steps on it because the radius doesn't seem to work. and with the other code that uses the @p variable it has the radius right but I can set the name property to no one on the server and it still teleports the closest person (it seems to teleport the closest person if it cant find the name, when I want it to teleport nothing if the name is not found). Maybe I need to add some redstone but I don't know if that would help.

share|improve this question
1  
Using arguments inside square brackets is only supported for @p, @r and @a, so the first one will not work at all. –  Alvin Wong Apr 7 '13 at 13:06
    
/tp does not work on some servers. Use /tpa [username] and hit enter. –  XxMinecraftxGirlxX May 12 '13 at 17:10
4  
@XxMinecraftxGirlxX /tp works on ALL servers, since it is a base minecraft command. –  Arperum May 13 '13 at 9:50

4 Answers 4

up vote 8 down vote accepted

If you only want to teleport people who are in a certain group, you can use the new scoreboard command to create a 'group' of people (using teams), and then teleport only that team with this command (targets nearest player in the group specified)

/tp @p[team=<internal group name>,<other params here>] <x> <y> <z>

To set up your groups, you can create a group like this:

/scoreboard teams add <internal group name> <display name>

And then add people to this group like this:

/scoreboard teams join <internal group name> <user name>

The advantage of this system is also that you can use it actually to separate groups in the actual game. The scoreboard command has a feature that means that the display name of a team will be displayed before the actual username, appearing like this in the chat:

[<display name>] <user name>: ...

More info on this system can be found in the wiki page linked above.


Changing the @p in the first command above to a player name will stop it from working, because parameters that are inside the [ and ] will only work for @p, @a, and @r. So you cannot substitute the first command above to /tp <player name>[r=2] <x> <y> <z>. It just won't work.
If you really want to use the r parameter on a single person, try using the above method that uses teams, but only put one person in the team. Here is a quick way to do this. Type these into the command console:

/scoreboard teams add <internal player name> <external player name>
/scoreboard teams join <internal player name> <player name>

And then in the command block, to teleport that person if they are in a radius of 2, you could use:

/tp @p[team=<internal player name>,r=2] <x> <y> <z>

Alternatively, you could just specify the name of the player in the selector. Following the previous example, if you want to teleport a certain person if they are in a radius of 2, you could use:

/tp @p[name=<player name>,r=2] <x> <y> <z>
share|improve this answer
    
This works REALLY well for what I want it to do when I'm in 1.5 or after, thank you for the answer, FTB is still in 1.4.7 so I will just have to wait to use your solution ^_^; –  BornToDoStuff Apr 9 '13 at 13:20

How about specifying the search center?

/tp @p[x=1234,y=64,z=5678,r=2,name=<player name>] <X> <Y> <Z>

or the shorthand

/tp @p[1234,64,5678,2,name=<player name>] <X> <Y> <Z>

I believe if you don't specify the search center, it uses the position of the command block itself.

(Source: Minecraft Wiki)


To response to OP's edit:

with the other code that uses the @p variable it has the radius right but I can set the name property to no one on the server and it still teleports the closest person (it seems to teleport the closest person if it cant find the name, when I want it to teleport nothing if the name is not found).

No, this doesn't happen to me when I test on 1.5.1.

share|improve this answer
    
this is 1.4.5 or right around there because its FTB ultimate pack. None of the mods in FTB change how the command blocks work and I'm pretty sure I'm not using anything that should affect how teleporting works, especially vanilla teleporting. –  BornToDoStuff Apr 7 '13 at 13:27
1  
@BornToDoStuff It is possible that the name argument is supported later than 1.4.5. The entry on Minecraft Wiki is added on 31st January, which I believe is somewhere near snapshot 13w05a (1.5 snapshot) –  Alvin Wong Apr 7 '13 at 13:42
    
hmm, this could be possible, if so I would have to use the actual player name and not the name argument. But I have tried it and it doesnt like me using the radius command with it, maybe it isnt possible in 1.4.5 and I'll have to wait till FTB updates –  BornToDoStuff Apr 7 '13 at 16:17

You could use /tp @p[r=2, m=1] x y z That way it will only effect people in gamemode 1 (creative) and you can make buttons that only work for any other game modes with 0=survival 1=creative 2=adventure 3=spectator. I hope that helps!

share|improve this answer

Well, you can actually use

/tp @a[name=<PlayerName>,name=<PlayerName2>] <coords>

And you can keep adding name= as many times as you want.

share|improve this answer
    
That would teleport everyone named, no matter how far away they are. That's almost the opposite of what they're trying to do. –  SevenSidedDie Jun 21 '13 at 22:45
    
but couldn't you set a radius, meaning that only if those players got within the radius would they be teleported? –  user70257 Feb 27 at 22:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.