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

What is wrong?

Discussion in 'Development' started by #A6543, Feb 21, 2017.

  1. MioTaku

    MioTaku Witch

    Messages:
    69
    GitHub:
    uselesswaifu
    Sorry if this sounds rude but you aren't suppose to run anything in LoginEvent the Recieve Event runs by itself when the player joins
     
    applqpak likes this.
  2. #A6543

    #A6543 Zombie

    Messages:
    267
    But it does nothing onJoin!
     
  3. #A6543

    #A6543 Zombie

    Messages:
    267
    How do I need to use the code to get it work?
     
  4. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    facepalm do you even read error?
    you need to pass DataPacketReceiveEvent NOT Player to onDataPacket
     
    applqpak likes this.
  5. #A6543

    #A6543 Zombie

    Messages:
    267
    Without $player it also don't work...

    Error without $player:
    Code:
    Argument 1 passed to Plugin\Main::onDataPacket() must be an instance of pocketmine\event\server\
    DataPacketReceiveEvent, none given,
     
  6. MioTaku

    MioTaku Witch

    Messages:
    69
    GitHub:
    uselesswaifu
    Remove the code for PlayerPreLoginEvent
     
  7. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    seriously?
    After you got the name WHAT IN HE*L do you want to do with $this->onDataPacket? You already got your $name now. What do you want to do after all?
     
    applqpak likes this.
  8. #A6543

    #A6543 Zombie

    Messages:
    267
    Than nothing happends!!! I already said that
     
  9. #A6543

    #A6543 Zombie

    Messages:
    267
    I already said, that the name was an example -_-
     
  10. EdwardHamHam

    EdwardHamHam Skeleton

    Messages:
    962
    GitHub:
    edwardhamham
    So than what do you want to do?!
     
  11. #A6543

    #A6543 Zombie

    Messages:
    267
    I want to get username from the LoginPacket
     
  12. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    Why do you have to get it from the packet? If possible, you should always try to use event listeners instead of handling packets in your plugin. If the username is just an example, what other data aside from the username do you want from the packet?
     
    applqpak and EdwardHamHam like this.
  13. #A6543

    #A6543 Zombie

    Messages:
    267
    That doesn't matter. I asked how I can get the username
     
  14. EdwardHamHam

    EdwardHamHam Skeleton

    Messages:
    962
    GitHub:
    edwardhamham
    Which we told you. You're confusing me, do you want to get the player's username, or is that just an example, or what? It's hard for anyone to help you if we don't know.
     
  15. #A6543

    #A6543 Zombie

    Messages:
    267
    I want to get the username using the Packet -_-
     
  16. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    This was already answered here. You simply used it incorrectly. If you want to echo or use the username you received later, you can save it to an array or variable.

    Your attempt isn't logical. You don't have a data packet to pass to the onDataPacket() function. You certainly can't pass a Player class to it.

    If you can't explain EXACTLY what you want to do, you won't get much more help.
     
    Redux and EdwardHamHam like this.
  17. #A6543

    #A6543 Zombie

    Messages:
    267
    But in what event can I echo the name?
     
  18. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    If you store it properly in an array or variable, you can use it anywhere.
     
  19. #A6543

    #A6543 Zombie

    Messages:
    267
    Lol.
    I only want to echo it onJoin
     
  20. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    That is possible. Pointless, but possible.
     
  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.