Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Teleport player to x y z

Comments in 'Plugin Development' started by IcePL, Mar 19, 2016.

  1. IcePL
    Offline

    IcePL New Member

    Joined:
    Feb 16, 2016
    Posts:
    73
    Minecraft User:
    IcePL
    Hi how to teleport player to x y z?
    To -148 79 94 (this is a random position)
    I make a /shop command and i need this
  2. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    $Pos = new Vector3($x, $y, $z)
    Player::teleporz($Pos);
  3. korado531m7
    Offline

    korado531m7 Active Member

    Joined:
    Apr 4, 2015
    Posts:
    158
    Minecraft User:
    korado531m7
    PHP:
    $pos = new Position(XYZLevel Name);
    $player->teleport($pos);
    AndrewBit and Survingo like this.
  4. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    $player->teleport(new Position(-148, 79, 94, Server::getLevelByName("world_name")), 0, 0);
    korado531m7 and Survingo like this.
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    It must be level object, not level name.
    Please, ClassName:: methodName() is only a syntax used when referring to a class method. If you are putting it in the middle of code, please use the proper nonstatic syntax.
    Hotshot_9930 and korado531m7 like this.
  6. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    Exactly what I was doing: referring to a class method. .-.
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Yes, but it is in the middle of code. Then why didn't you say Player::teleport() rather than $player->teleport()? You are making people think that Server::getLevelByName() is a static function.
  8. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    I didn't notice that, no need to be strict. People need to learn the PocketMine API. Teleporting player's is like one of the easiest things to do.
    AndrewBit and Survingo like this.
  9. IcePL
    Offline

    IcePL New Member

    Joined:
    Feb 16, 2016
    Posts:
    73
    Minecraft User:
    IcePL
    Ok thanks for help
  10. WitherTube
    Offline

    WitherTube New Member

    Joined:
    Dec 21, 2015
    Posts:
    44
    Minecraft User:
    Wither_Tube
    You can make it like this :
    PHP:
    public function onLogin(PlayerLoginEvent $event)
    {
    $player $event->getPlayer();
    $player->teleport(new Vector($x$y$z));
    }
  11. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    If you were to actually use it in the code it would crash, due to the fact that getLevelByName() is not a static method.

Share This Page

Advertisement