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

Problem With Teleport

Discussion in 'Development' started by Nawaf1b, Jun 29, 2018.

  1. Nawaf1b

    Nawaf1b Silverfish

    Messages:
    17
    Hello.
    I Have some problem with teleport to another world .
    I Load Level in onEnable Function at the first time Teleport its work after Finish Game
    i unload The Level and Load Level In this case Teleport to another World its not work
    ---
     
    Last edited: Jun 29, 2018
  2. Mespeczek

    Mespeczek Silverfish

    Messages:
    15
    GitHub:
    Igomisz123
    use that

    PHP:
                        if(!$sender->getServer()->isLevelLoaded($args[0])){
                            if(!
    $sender->getServer()->loadLevel($args[0])){
                                
    $sender->sendMessage(TextFormat::RED"Level is not loaded");
                            }
                        }
                        
    $sender->teleport($this->getServer()->getLevelByName($args[0])->getSpawnLocation(), 0);
    the world is automatically loaded
     
  3. Nawaf1b

    Nawaf1b Silverfish

    Messages:
    17
    doesnot work
     
  4. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    Is there an error? What happens when you run the command?
     
  5. Nawaf1b

    Nawaf1b Silverfish

    Messages:
    17
    Its Teleport me In My Deffault World
     
  6. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    So it does teleport you, which means it works, just not as intended. What is the name of your default world, and what world name did you use in your command?
     
  7. Nawaf1b

    Nawaf1b Silverfish

    Messages:
    17
    LuckyBlock
     
  8. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    And what is the other world name?
     
  9. Nawaf1b

    Nawaf1b Silverfish

    Messages:
    17
    The Deffault World : Mini3rb
     
  10. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    Try something like this:
    PHP:
      /** @Player $player */
      
    $worldName "LuckyBlock";
      
    $player->teleport($this->getServer()->getLevelByName($worldName)->getSafeSpawn());
    Of course, if you're using a command, you can make $worldName = $args[0].
     
  11. Nawaf1b

    Nawaf1b Silverfish

    Messages:
    17
    ^
     
  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.