Hello guys. I'm trying to make teleport with PlayerMoveEvent, but it doesn't work. I want if player is on xyz position, plugin will teleport to another position. PHP: public function onMove(PlayerMoveEvent $e){$p=$e->getPlayer();if($p->x >= 128 && $p->x <= 118 && $p->y > 11 && $p->z == 177){$p->teleport(new Position(162, 67, 92, $this->getServer()->getLevelByName("priroda")));}}
The code you've send should work. Have you registered the events on plugin enable? Try debugging the code else.
You mixed up the bigger as and smaller as symbols. It should be: PHP: $p->x <= 128 && $p->x >= 118 And it is almost impossible for a player to stand on an integer coordinate. So add floor(), to round down: PHP: if($p->x <= 128 && $p->x >= 118 && $p->y > 11 && floor($p->z) == 177){
Well, some think using onPlayerMove() is creating unnecessary lag, as it can be called more than once within a tick
im using move event in my anticheat and i didn't notice any bigger lag, and i run a lots of checks in it
You want to tell event what is x,y,z PHP: $x = round($player->getX());$y = round($player->getY());$z = round($player->getZ());
to use this PHP: if($p->x >= 128 && $p->x <= 118 && $p->y > 11 && $p->z == 177){ He want to tell what is x,y,z