PHP: public function onRespawn(PlayerRespawnEvent $event){ $player = $event->getPlayer(); if($this->isInGame($player->getName()) == true && $this->getState() == true){ echo "\n It's ok!"; $TeamFile = new Config($this->getDataFolder()."Game/team.yml",Config::YAML); $team = $this->getTeam($player->getName()); $number = $this->getNumberOfTheTeam($player->getName()); $x = $TeamFile->getNested($team . "." . $number . ".pos.x"); $y = $TeamFile->getNested($team . "." . $number . ".pos.y"); $z = $TeamFile->getNested($team . "." . $number . ".pos.z"); $player->teleport(new Vector3($x,$y,$z,$this->getLevel())); } } I tried numbers rather than get it from data folder but it doesn't work at all just " echo " line work the teleport part not work and I don't know why! Is it exist to teleport when press respawn?
No, no error in console. and I tried give coordinates are actually valid and also not work. maybe teleport can't code in PlayerRespawnEvent I don't know
i remembered i got this issue before, when playerrespawnevent get called, player will be teleport, so i couldnt teleport player in this function.My way was canceled the deathevent and teleport the player in that funcion, otherwise you can try calling a delayed task to teleport player after few ticks
so if that might true I should make spawnpoint rather than teleport I'll see if no-one help I'll do that
https://github.com/pmmp/PocketMine-MP/blob/stable/src/pocketmine/Player.php#L3643 It doesnt work because the server teleports the player after the event gets called, use PHP: $event->setRespawnPosition(new Position($x,$y,$z,$this->getLevel())) instead
Is this for the all player or just replace " $event " with " $event->getPlayer() ". I see thx for help : )