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

getSafeSpawn()

Comments in 'Plugin Development' started by cake23, Feb 15, 2016.

  1. cake23
    Offline

    cake23 Active Member

    Joined:
    Aug 10, 2015
    Posts:
    124
    Minecraft User:
    TheEnd
    Code:
    Fatal Error: Call to member function getSafeSpawn() on null in.....on line 86.
    I cant teleport a player to a world? Does anyone know why?
    PHP:
    if($sign instanceof \pocketmine\tile\Sign) {
                if (
    $this->schildRegistrieren === false) {
                    
    $text $sign->getText();
                    
    $level $this->getServer()->getLevelByName($text[1]);
                    if (
    $text[0] === $this->prefix) {
                        
    $inDerWelt 0;
                        if(
    $inDerWelt 16 && !($text[3] === "§cVoll")) {
                            
    $teleportSound = new EndermanTeleportSound($player);
                            
    $player->getLevel()->addSound($teleportSound);
                            
    $levelName $level->getName();
                            
    $this->getServer()->loadLevel($levelName);
                            
    $player->teleport($level->getSafeSpawn());
                            
    $player->getInventory()->clearAll();
                            
    $inDerWelt++;
    Thanks!
  2. TutoGamerWalid
    Offline

    TutoGamerWalid Active Member

    Joined:
    Jun 11, 2015
    Posts:
    69
    Minecraft User:
    TutoGamerWalid
    PHP:
    $player->teleport($this->getServer()->getLevelByName($level)->getSafeSpawn());
  3. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    $level is already a Level object.
    applqpak likes this.
  4. cake23
    Offline

    cake23 Active Member

    Joined:
    Aug 10, 2015
    Posts:
    124
    Minecraft User:
    TheEnd
    Can no one help me? ._.
  5. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    Just found out.
    did the second line of the sign contain the RIGHT worldname? because that means it does not exist
  6. cake23
    Offline

    cake23 Active Member

    Joined:
    Aug 10, 2015
    Posts:
    124
    Minecraft User:
    TheEnd
    PHP:
    $level $this->getServer()->getLevelByName($this->levelName);
                    
    $inDerWelt count($level->getPlayers());
                    
    $fullOrNot "";
                    if(
    $inDerWelt 16) {
                        
    $fullOrNot "§aBeitreten";
                    } else {
                        
    $fullOrNot "§cVoll";
                    }
                    
    $sign->setText($this->prefix$this->levelNameTextFormat::AQUA."[".$inDerWelt."/16"."]"$fullOrNot);
                    
    $this->schildRegistrieren false;
                    
    $player->sendMessage($this->prefix.TextFormat::GREEN."Du hast erfolgreich ein Schild für ".$this->levelName." gesetzt!");
                    
    $this->levelName "";
    The second line is the world name.. :/
  7. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    Whats SchildRegistrieren? For werden t did you need it?
    German:
    Für was brauchst du SchildRegistrieren?
    Du kannst ja einfach die Linien abchecken
  8. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Forum = English only.
    + Understand the code before replying.
    Change
    PHP:
    $levelName $level->getName();
    to
    PHP:
    $levelName $text[1];
  9. cake23
    Offline

    cake23 Active Member

    Joined:
    Aug 10, 2015
    Posts:
    124
    Minecraft User:
    TheEnd
    Okay thanks, I will try it out. :3
  10. cake23
    Offline

    cake23 Active Member

    Joined:
    Aug 10, 2015
    Posts:
    124
    Minecraft User:
    TheEnd
    Its for checking if the player will register a sign for an arena. Sorry, its an English only forum, I cant answer in German. :p
  11. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Either the level doesnt exist, or it isn't loaded.

    Try loading it onEnable
    applqpak likes this.
  12. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    I think that getSpawnLocation() is already good enough for most purposes :D
    applqpak likes this.
  13. CaptainKenji17
    Offline

    CaptainKenji17 Active Member

    Joined:
    Apr 22, 2014
    Posts:
    252
    Minecraft User:
    CaptainKenji17
    whole plugin pls u may be forgotten some use pocketmine...
  14. Nawaf_Craft1b
    Offline

    Nawaf_Craft1b Active Member Plugin Developer

    Joined:
    May 8, 2015
    Posts:
    232
    Plugins:
    1
    Minecraft User:
    Nawaf_Craft1b
    I Think You Forgot
    PHP:
    public function onEnable(){
    // code
    $this->getServer()->loadLevel($this->levelname);
    }
  15. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    He loaded it on his code, please read before answering..
    Omar2s2 and Nawaf_Craft1b like this.
  16. Nawaf_Craft1b
    Offline

    Nawaf_Craft1b Active Member Plugin Developer

    Joined:
    May 8, 2015
    Posts:
    232
    Plugins:
    1
    Minecraft User:
    Nawaf_Craft1b
    OKEY
    Thx :)
    Last edited: Feb 17, 2016
    Omar2s2 likes this.

Share This Page

Advertisement