PHP: public function onTap(PlayerInteractEvent $ev) { $player = $ev->getPlayer(); $item = $player->getInventory()->getItemInHand()->getId(); if($item === 345){ So, I want to transfer players to another server when they tap the compass(345) to the ground
use PlayerTransferEvent (https://github.com/pmmp/PocketMine-...mine/event/player/PlayerTransferEvent.php#L47)
The event, which is fired while a player is transferred, is totally not relevant when you want to initiate a transfer. Please do not provide unhelpful answers.
PHP: public function onTap (PlayerInteractEvent $event) { $player = $event->getPlayer(); $item = $player->getInventory()->getItemInHand()->getId(); if ($item === 345) { $player->transfer("play.example.com", 19132); }} The second parameter in the transfer function is optional, by default the value is 19132.