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

teleport player to playee

Discussion in 'Development' started by Zuruki, Apr 14, 2017.

  1. Zuruki

    Zuruki Baby Zombie

    Messages:
    118
    GitHub:
    zuruki
    So, how would you teleport a player to another player?
    I've defined $player1 as $sender->getPlayer();

    PHP:
    $player2 $args[0];
    if(
    $player2 instanceof Player){
    $player1->teleport($player2);
    is this right? Or, do I have to grab player2's xyz?
    if so, what if $player2 was in a different level?
     
  2. DanielYTK

    DanielYTK Zombie

    Messages:
    227
    Use this:
    PHP:
     $player2 $this->getServer()->getPlayer($args[0]);
    $sender->teleport($player2); 
     
    Zuruki likes this.
  3. Az928

    Az928 Baby Zombie

    Messages:
    140
    GitHub:
    theaz928
    PHP:
    $player2 $this->getServer()->getPlayer($args[0]);
    if(
    $player2 !== null){
      
    $pos = new Position($player2->getX(), $player2->getY(), $player2->getZ(), $player2->getLevel());
      
    $player->teleport($pos);
    }
     
  4. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    No point in constructing new positions. Just do $player->teleport($player2);
     
  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.