1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

PlayerTransferEvent don't transfer more players.

Discussion in 'Development' started by matcracker, May 14, 2017.

  1. matcracker

    matcracker Spider

    Messages:
    13
    GitHub:
    matcracker
    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.
     
  2. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    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.
     
    jasonwynn10 and corytortoise like this.
  3. matcracker

    matcracker Spider

    Messages:
    13
    GitHub:
    matcracker
    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.
     
  4. matcracker

    matcracker Spider

    Messages:
    13
    GitHub:
    matcracker
  5. 0x15f

    0x15f Baby Zombie

    Messages:
    145
    GitHub:
    0x15f
    Is PlayerTransferEvent called? Some events are in the source but aren't called.
     
  6. matcracker

    matcracker Spider

    Messages:
    13
    GitHub:
    matcracker
    Yes, it's called
     
  7. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    What about the packet? Does the transfer packet get sent twice, exactly to the two players?
     
  8. 0x15f

    0x15f Baby Zombie

    Messages:
    145
    GitHub:
    0x15f
    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.
     
  9. matcracker

    matcracker Spider

    Messages:
    13
    GitHub:
    matcracker
    How I said here, the players receive the packet and they are kicked for reason "transfer".
     
  10. matcracker

    matcracker Spider

    Messages:
    13
    GitHub:
    matcracker
    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
     
    SOFe likes this.
  11. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    He already has a check for name !== test2, so it won't be infinitely recursive, and there is nothing really wrong with using PlayerTransferEvent.
     
  12. matcracker

    matcracker Spider

    Messages:
    13
    GitHub:
    matcracker
    Can be a possible issue with transfer event?

    @dktapps
     
  13. matcracker

    matcracker Spider

    Messages:
    13
    GitHub:
    matcracker
    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
     
  14. SleepSpace9

    SleepSpace9 Slime

    Messages:
    78
    GitHub:
    sleepspace9
    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.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.