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

Solved How can I teleport players to certain coordinates?

Discussion in 'Plugin Help' started by MinekCz, Jul 9, 2020.

  1. MinekCz

    MinekCz Spider Jockey

    Messages:
    29
    I need to teleport players to certain coordinates (the world is not completely needed)

    My code:
    PHP:
      $this->arena1 $this->getConfig()->get("arena1");
      
    $this->arena1 $this->getConfig()->get("arena2");

      public function 
    tp(Player $player) {

        
    $level1 $this->getServer()->getLevelByName($this->arena1);
        
    $level2 $this->getServer()->getLevelByName($this->arena2);

        
    $ap1X $this->getConfig()->get("ap1X");
        
    $ap1Y $this->getConfig()->get("ap1Y");
        
    $ap1Z $this->getConfig()->get("ap1Z");
        
    $tpa1 = new Position($ap1X $ap1Y $ap1Z 0$level1);
        

        
    $ap2X $this->getConfig()->get("ap2X");
        
    $ap2Y $this->getConfig()->get("ap2Y");
        
    $ap2Z $this->getConfig()->get("ap2Z");
        
    $tpa1 = new Position($ap2X $ap2Y $ap2Z $level1);
        
        
    $bp1X $this->getConfig()->get("bp1X");
        
    $bp1Y $this->getConfig()->get("bp1Y");
        
    $bp1Z $this->getConfig()->get("bp1Z");
        
    $tpa1 = new Position($bp1X $bp1Y $bp1Z $level2);

        
    $bp2X $this->getConfig()->get("bp2X");
        
    $bp2Y $this->getConfig()->get("bp2Y");
        
    $bp2Z $this->getConfig()->get("bp2Z");
        
    $tpa1 = new Position($bp2X $bp2Y $bp2Z $level2);

        if (
    $player == $this->ap1$player->teleport($tpa1);
        if (
    $player == $this->ap2$player->teleport($tpa2);
        if (
    $player == $this->bp1$player->teleport($tpb1);
        if (
    $player == $this->bp2$player->teleport($tpb2);

      }
    I also tried to remove pitch and yaw, but I also got an error ...
     
  2. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    $this->arena1 = $this->getConfig()->get("arena2");
    I think it should be $this->arena2
    It would help if you tell us the error
     
  3. JviguyGamesYT

    JviguyGamesYT Baby Zombie

    Messages:
    113
    GitHub:
    jviguy
    easiest way to teleport a player to coordinates is vector three
    PHP:
    $player->teleport(new Vector3($x $y $z));
     
  4. FiraasMCPE

    FiraasMCPE Creeper

    Messages:
    4
    GitHub:
    firaasmcpe
    What does vector 3 mean? Like vector 3D?
     
  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.