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

Solved Positions Issue!

Discussion in 'Development' started by 7awariGamer, Jun 22, 2020.

  1. 7awariGamer

    7awariGamer Baby Zombie

    Messages:
    120
    GitHub:
    7awariGamer
    Hi, I am trying to to a player to a specific coordinates in a specific world and I am facing some problems, this is my code :
    PHP:
    case "obw go":
                  if(
    $sender instanceof Player)
                   {
                     
    $IslandName $sender->getName();
                     if(
    is_dir($this->getServer()->getDataPath() . "worlds/" $IslandName))
                      {
                        
    $level $sender->getServer()->getLevelByName($IslandName);
                        
    $sender->teleport($level->getSafeSpawn(new Vector3(25667256)));
                      }
                   }
    The player tps perfectly to the world but not for the exact positions, can someone help?
    - using PMMP 3.13.0 official
     
  2. Doxestic

    Doxestic Spider Jockey

    Messages:
    41
    this code can have 2 problems:
    1.if you want to tp the player it's better to don't use getSafeSpawn() function so you can use this code for tp:
    $sender->teleport(new Vector3(256, 67, 256));

    2.for subcommand don't check it in case you can use this code:

    PHP:
    switch($command->getName()){
        case: 
    "obw":
             if(
    $sender instanceof Player){
                  if(
    $args[0]/* for subcommand*/ == "go"){
                         
    $sender->teleport(new Vector3(25667256);
                  }
             }
    }
     
  3. Doxestic

    Doxestic Spider Jockey

    Messages:
    41
    and in line 7 of your code:
    $level = $sender->getLevel();
    or:
    $levelname = $sender->getLevel()->getName();
     
  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.