What are packets in plugin coding and how do they work? Can you drop a link to some tutorial or say where i can understand packets?
Packets are packets of information whose are sending between player and server. There are lots of packets in mcpe, you can find all implemented packets by pocketmine here. However with pocketmine api you don't need to use that classes so much because of you can replace them using simplier api methods. For example when you want send message to player, you will use PHP: Player->sendMessage($message); instead of PHP: $pk = new TextPacket();$pk->type = TextPacket::TYPE_RAW;$pk->message = $messagePlayer->dataPacket($pk); ^ In this case I show you how to send packet to player. Packets sent from client can be handled using DataPacketReceiveEvent, so you can check all the packets whose server handled using it.... There is also DataPacketSendEvent which is called when packet is send to player.
My question is what does player-> dataPacket ($ pk) mean. I realized that this sends a packet to the player, but what is the “player” in the code itself, it is not a variable, but what then? And is it possible to write like this: foreach($this->getServer()->getOnlinePlayers() as $p){ $p->dataPacket($pk); } ??? And packets load the server??? And one more question: That is, functions in the server software PocketMine-MP work with packages, and when they are executed, are packages created? Thank you very much again. And if you want, then do not answer the questions above. You already helped me, thanks
Learn php basics first, then you will understand this stuff. - Player is class located at \pocketmine\Player.php - your code should work