PHP: public function TeleportToArea($player) { $world = $this->getPlugin()->getServer()->getLevelByName("Location"); $player->teleport($world->getSafeSpawn()); $player->teleport(new Vector3(344, 155, 329, 0, 0)); } public function onPlayerMove(PlayerMoveEvent $event) : void{ $player = $event->getPlayer(); $level = $player->getLevel(); $X = $player->getX(); $Y = $player->getY(); $Z = $player->getZ(); if(23 == $X and "-19" == $Z and $this->getPlugin()->getServer()->getLevelByName("world") == $level) { $this->TeleportToArea($player); }} This is the code I have, but when I run this code nothing happens.
XYZ can be a float. (https://github.com/pmmp/PocketMine-...dc9/src/pocketmine/level/Location.php#L35-L38) Try dumping $X, $Y, and $Z.
I got my xyz cords, but as soon as put that into an if statement to check for the specific cords, nothing happens
Answer my question please. From what I’m assuming, you got a float which you put for your coordination, but you can’t access it again because the float was too intense
Try changing your If statement to this PHP: if($X == 23 and $Z == -19 and $level->getName() == "world")
Add echo statements every where. Eg: Echo(“1”) and so on. Add one before the if statement After the if statement And so on
I've already tried that using logger, it just doesn't run the part of the code because the if statement is never triggered.
PHP: public function TeleportToWorld(Player $player) { $world = $this->getPlugin()->getServer()->getLevelByName("TeleportWorld"); $player->teleport($world->getSafeSpawn()); $player->teleport(new Vector3(344, 155, 329, 0, 0)); } public function warpFromSpawn(Player $player, float $x, float $z) { $X = $player->getX(); $Y = $player->getY(); $Z = $player->getZ(); $level = $player->getLevel(); if($X == $x and $Z == $z and $level->getName() == "world") { $this->TeleportToWorld($player); } } public function onPlayerMove(PlayerMoveEvent $event) : void{ $player = $event->getPlayer(); $player->sendMessage($player->getX() . $player->getZ()); $this->warpFromSpawn($player, 23, -19); $this->warpFromSpawn($player, 24, -19); $this->warpFromSpawn($player, 25, -19); $this->warpFromSpawn($player, 26, -19); $this->warpFromSpawn($player, 23, -18); $this->warpFromSpawn($player, 24, -18); $this->warpFromSpawn($player, 25, -18); $this->warpFromSpawn($player, 26, -18); } This is the code for the process
Separate your if functions. Eg: If(XOne){ Echo(“1”); If(ZTwo){ echo(“2”); } } This is going to tell us which if function isn’t working
PHP: [18:31:45] [Server thread/NOTICE]:[18:31:47] [Server thread/NOTICE]: line 81[18:31:47] [Server thread/NOTICE]: line 81[18:31:47] [Server thread/NOTICE]: line 81[18:31:47] [Server thread/NOTICE]: line 81[18:31:47] [Server thread/NOTICE]: line 81[18:31:47] [Server thread/NOTICE]: line 81[18:31:47] [Server thread/NOTICE]: line 81[18:31:47] [Server thread/NOTICE]: line 81[18:31:47] [Server thread/NOTICE]: line 81[18:31:47] [Server thread/NOTICE]: line 81[18:31:47] [Server thread/NOTICE]: line 81[18:31:47] [Server thread/NOTICE]: line 81[18:31:47] [Server thread/NOTICE]: line 81[18:31:47] [Server thread/NOTICE]: line 81[18:31:47] [Server thread/NOTICE]: line 81[18:31:47] [Server thread/NOTICE]: line 81[18:31:47] [Server thread/NOTICE]: line 81[18:31:47] [Server thread/NOTICE]: line 81[18:31:47] [Server thread/NOTICE]: line 81[18:31:47] [Server thread/NOTICE]: line 81[18:31:47] [Server thread/NOTICE]: line 81[18:31:47] [Server thread/NOTICE]: line 81[18:31:47] [Server thread/NOTICE]: line 81[18:31:47] [Server thread/NOTICE]: line 81[18:31:47] [Server thread/NOTICE]: line 81[18:31:47] [Server thread/NOTICE]: line 81[18:31:47] [Server thread/NOTICE]: line 81[18:31:47] [Server thread/NOTICE]: line 81[18:31:47] [Server thread/NOTICE]: line 81[18:31:47] [Server thread/NOTICE]: line 81[18:31:47] [Server thread/NOTICE]: line 81[18:31:47] [Server thread/NOTICE]: line 81[18:31:47] [Server thread/NOTICE]: line 81[18:31:47] [Server thread/NOTICE]: line 81[18:31:47] [Server thread/NOTICE]: line 81[18:31:47] [Server thread/NOTICE]: line 81[18:31:47] [Server thread/NOTICE]: line 81[18:31:47] [Server thread/NOTICE]: line 81[18:31:47] [Server thread/NOTICE]: line 81 PHP: $this->plugin->getServer()->getLogger()->notice("line 81"); if($X == $x and $Z == $z and $level->getName() == "world") { $this->plugin->getServer()->getLogger()->notice("line 83"); $this->TeleportToPvP($player); $this->plugin->getServer()->getLogger()->notice("line 85"); This is what happens, no 83 or 85 line was noticed, only 81 was