You're sending an empty Login packet and expect it to work? Hm? If you're creating a packet you'll have to do $pk->username = $username;...
How can I get the name in the PlayerLogin packet?? I don't want to use other packets. I need to get it from PlayerLogin
and use print_r/var_dump afaik you can do things like $packet->usrnm = $rank." ".$packet->usrnm as a very bad example
$pk->username? PHP: public function onDataPacket(\pocketmine\event\server\DataPacketReceiveEvent $ev){ $packet = $ev->getPacket(); if($packet instanceof \pocketmine\network\protcol\LoginPacket){ $username = $packet->username; } }
Just freaking tell us that you want to get the username on PlayerJoinEvent /** @var $ev PlayerJoinEvent */ $name = $event->getPlayer()->getName();
Error: Code: Argument 1 passed to Plugin\Main::onDataPacket() must be an instance of pocketmine\event\server\ DataPacketReceiveEvent, instance of pocketmine\Player Code: PHP: public function onDataPacket(\pocketmine\event\server\DataPacketReceiveEvent $ev){ $packet = $ev->getPacket(); if($packet instanceof \pocketmine\network\protcol\LoginPacket){ $username = $packet->username;echo "-> ".$username; } }public function onPPreLogin(PlayerPreLoginEvent $event) { $player = $event->getPlayer();$name = $player->getName();$this->onDataPacket($player);