1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

How to teleport to another world?

Discussion in 'Plugin Help' started by MalakasPlayzMC, May 18, 2017.

  1. MalakasPlayzMC

    MalakasPlayzMC Spider Jockey

    Messages:
    37
    How could I teleport to a world?
    To teleport in some specific coordinates I used the code:
    PHP:
                $x = {x};
                
    $y = {y};
                
    $z = {z};
                
    $player->teleport(new Vector3($x$y$z));
     
  2. falk

    falk Slime Poggit Reviewer

    Messages:
    75
    GitHub:
    falkirks
    PHP:
    $x = {x};
    $y = {y};
    $z = {z};
    $level $player->getServer()->getLevelByName("levelName");
    $player->teleport(new Position($x$y$z$level));
    EDIT: Fixed function call (thanks @Sandertv )
     
    Last edited: May 18, 2017
    jasonwynn10 and Sandertv like this.
  3. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    Small correction, $server->getLevel() requires a level ID parameter. To get a level from a name, you should use $server->getLevelByName($name)
     
    jasonwynn10 and falk like this.
  4. MalakasPlayzMC

    MalakasPlayzMC Spider Jockey

    Messages:
    37
  5. Lowkey

    Lowkey Slime

    Messages:
    94
    Move to development?
     
    jasonwynn10 likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.