Hello guys. I have a problem, that seems a PMMP problem. Problem: Supposing that I need to transfer 2 online players (tester1 and tester2) between two servers. When tester1 start transfer (for example using /transferserver command), tester2 will start transfer in the same server where tester1 is addressed. What happens? Both players are kicked for transfer but they aren't connected to the other server. Code: PHP: public function onPlayerTransfer(PlayerTransferEvent $event){ $player = $event->getPlayer(); //Initially is tester1 that evoke that event, after will be tester2 if ($player->getName() !== "tester2") //Check if isn't himself $this->getServer()->getPlayer("tester2")->transfer("localhost", 19133);//Transferring tester2 and re-evoke that event} How can I resolve? Thanks.
Not sure if you really mean "localhost" here. The first parameter in the transfer() function is to be resolved by the client. To you, localhost works, but to players, localhost means their own device and it is probably not what you intend.
No, I tried to transfer each single player with that command using the same parameters for both players and it works. So, why shouldn't work with transfer event? Obliviously, I'm just testing in local net.
If the player is being transferred twice the function would be recursive. Try using PlayerQuitEvent, and check the reason the player is quitting, then transfer tester2.
I'm not trying to transfer two times the same player. I'm trying to transfer two different players to the same server. I summarize the problem: 1- Player1 start to transfer 2- PlayerTransferEvent is called 3- Event transfers Player2 to the same Player1 address 4- Another PlayerTransferEvent is called 5- Check if player isn't already transferred, so, nothing happens. (This avoid a event loop without server crash) 6- Player2 kicked for transfer then Player1 is kicked (Console log sequence). 7- Anyone player is connected to the other server
He already has a check for name !== test2, so it won't be infinitely recursive, and there is nothing really wrong with using PlayerTransferEvent.
I try to edit transfer method of PocketMine and removing the line PHP: $this->close("", $ev->getMessage(), false); the issue seems fixed. I research if someone else has my problem, and I found that in pmmp repo on #497
After sending the TransferPacket with immediate priority I was unable to reproduce the issue, but later I did notice that in some rare cases I still experienced the disconnect (I think when the client was also spammed with many other packets at the same time - not proved just a guess). Sorry for not reporting it, as I said it doesn't happen very often to me.