how to cancel "You teleported to spawn"??? i made a minigame but if u die u will be teleported automaticly to mainworld spawn. how to cancel this ?
if i use this: Spoiler: code public function onPlayerRespawnEvent(PlayerRespawnEvent $event) { if ($event->getPlayer()->getLevel()->getName() == in_array($event->getPlayer()->getLevel()->getName(), $this->config->get("Spielwelt"))) { $event->setCancelled(); } } then i get this error Spoiler: code PocketMine-MP Crash Dump Thu Nov 13 13:06:14 UTC 2014 Error: Event is not Cancellable File: /src/pocketmine/event/Event Line: 69 Type: error Code: [60] /** [61] * @param bool $value [62] * [63] * @return bool [64] * [65] * @throws \BadMethodCallException [66] */ [67] public function setCancelled($value = true){ [68] if(!($this instanceof Cancellable)){ [69] throw new \BadMethodCallException("Event is not Cancellable"); [70] } [71] $this->isCancelled = (bool) $value; [72] } [73] [74] /** what can i do ?
PlayerRespawnEvent cannot be cancelled. In other thinking, it is impossible to disallow player to click the respawn button. Change spawn position by setRespawnPosition().
i cant because the minigame is on a other world xD and if u die u spawn back to mainworld i can teleport the player after death to the right position but after 1 second the game teleports the player to the server spawn point
stop, with the entitydeath event i can teleport the player to a current position. after that the game teleport me back to the world spawn. but how i get it after the last teleport tospawn? with lvl change event ^^? --edit hm i think lvl change is fail ...
Read... To instantiate a position: PHP: use pocketmine\level\Position;...$level = $server->getLevelByName($levelName);$position = new Position($x, $y, $z, $level);
but what if you only want only teleport back to home from this level, then the same effect and that is not what i want. thats right and i can use this but by death. the teleport goes happends befor - then the simple respawn to main world so nothing helps...
Then get the object of this level. No. The teleportation goes right after PlayerRespawnEvent is called. Therefore, you can use $event->setRespawnPosition(Position) to change the position where the player is teleported to for respawning.
onPlayerRespawnEvent $position = new Vector3(x, y, z); $event->setRespawnPosition($position); this is usefull thank u at first - but i get an notice in console after each death in "Spielwelt" 11:40:20 [NOTICE] An E_RECOVERABLE_ERROR error happened: "Argument 1 passed to pocketmine\event\player\PlayerRespawnEvent::setRespawnPosition() must be an instance of pocketmine\level\Position, instance of pocketmine\math\Vector3 given, called in phar:///home/mcpe3/plugins/SurvivalHiveMinigame.phar/src/main/minigame.php on line 187 and defined" in "/src/pocketmine/event/player/PlayerRespawnEvent" at line 55 ---edit GOT IT!!! new Position(x, y, z) is better ^^^THX FOR HELP!!!
Use new Position() instead of new Vector3(). Just put the level the player is currently in (Player::getLevel()) for the level.
[QUOTE=" Just put the level the player is currently in (Player::getLevel()) for the level.[/QUOTE] dont need this make it with a other - if () - code but thanks for help!!!
dont need this make it with a other - if () - code but thanks for help!!![/QUOTE] I don't understand. What do you mean?
The player is still in a level. Do you want to always teleport to the same world or to the current world the player is in?
it works fine =) if u are in minigame world and u die u respawn in the same world at the setted position. and the best thing if u do it with the death event as well - your stuff dont gone ^^ so you can rescue your stuff by death