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

how to tp player to spawn on respawn ?

Comments in 'Plugin Development' started by Svile, Jun 29, 2015.

  1. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    Hi , i need to teleport players to spawn on respawn, i tried that :
    PHP:
    public function onRespawn(PlayerRespawnEvent $event){                                  
                
    $level $this->plugin->getLevel($this->plugin->config->get("LobbyName"));
                
    $spawn $this->plugin->getSpawn($this->plugin->config->get("LobbyName"));
                
    $player $event->getPlayer();
               
                
    $level->loadChunk $level->getSafeSpawn ()->x$level->getSafeSpawn ()->);
                
    $player->teleport $level->getSafeSpawn () );
            
    $level->loadChunk $spawn[0], $spawn[2] );
                
    $player->teleport ( new Vector3 $spawn[0], $spawn[1], $spawn[2] ) );
                unset(
    $level);unset($spawn);                                       
            
                
    $player->sendMessage(TextFormat::GREEN.$this->plugin->lang->get("RespawnMessage"));
                unset(
    $player);              
        }
    the message is send to the player , no errors in the console but the player isn' t teleported.
    i also tried MSpawns ... the same result
  2. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    I would do
    PHP:
    $player->teleport($spawn);
    // Or
    $player->teleport($this->plugin->getLevelByName($this->plugin->config->get("LobbyName"))->getSpawn());
  3. aliuly
    Offline

    aliuly Notable Member Plugin Developer

    Joined:
    Feb 8, 2014
    Posts:
    1,086
    Plugins:
    17
    Try SpawnMgr.
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    I told you to use respawn, but not telephoto in response... Set the respawn position.
  5. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    The teleport works only after the respawn for example SpawnMgr teleport the player after 10 ticks ... I don' t know why

Share This Page

Advertisement