Hi, I've been having some trouble with the teleport() function. When I try to teleport a player to a certain coordinate, it gives me an error and shuts down the server as soon as I join the server or fails to teleport the player. Here is the code: Spoiler: Code PHP: namespace Some\Random\Namespace;use pocketmine\event\Listener;use pocketmine\event\player\PlayerJoinEvent;use pocketmine\math\Vector3;use pocketmine\plugin\PluginBase;class Hub extends PluginBase implements Listener { public function onEnable() { $this->getLogger()->info("MyPlugin is up and ready to welcome people to NatalieCraft!"); $this->getServer()->getPluginManager()->registerEvents($this, $this); } public function onPlayerJoin(PlayerJoinEvent $event) { $event->getPlayer()->sendMessage("§eHey There! Welcome to §cNatalieCraft§e, we're glad to see you!"); $event->setJoinMessage("§c".$event->getPlayer()->getName()." §ehas joined the game."); $event->getPlayer()->teleport(new Position(0, 5, 0)); }
Maybe "error" is the wrong term. In the console it's not giving me any errors, it's just not teleporting the player.
hehe... srry I'm not too clear about this stuff. I'm just wondering why my player is not being teleported to (0, 5, 0) when he logs on.
Teleport the player through PlayerRespawnEvent. PlayerRespawnEvent is called after the player died-and-respawned or after the player joined.
PlayerLoginEvent is good, too! (PlayerLoginEvent will be called before the yellow text appears and PlayerRespawnEvent after the yellow text appears) I am using only PlayerLoginEvent because my serverCore plugin has much to do on the playerlogin and i want that yellow text after that!