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

SetEntityDataPacket

Discussion in 'Facepalm' started by LucGamesDE, Jul 3, 2017.

  1. LucGamesDE

    LucGamesDE Baby Zombie

    Messages:
    170
    I tried to set different names for a player. For example: for player1 player has the name "Hello1" and for player2 player's name ist "Hello2". But. Don't know how to do that :/

    I already tried SetEntityDataPacket. But it didn't change anything
     
  2. LucGamesDE

    LucGamesDE Baby Zombie

    Messages:
    170
    Why was this moves to facepalm?
     
  3. Intyre

    Intyre Administrator Staff Member PMMP Team

    Messages:
    81
    GitHub:
    Intyre
  4. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    how are you trying to set their names? do you mean their nametags, their display list name, or something else?
     
  5. LucGamesDE

    LucGamesDE Baby Zombie

    Messages:
    170
    Oh sorry. I want to set the nametag
     
  6. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
  7. LucGamesDE

    LucGamesDE Baby Zombie

    Messages:
    170
  8. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    okay, then set the nametags different lol
    $player1->setNameTag("Steve");
    $player2->setNameTag("Alex");
     
  9. LucGamesDE

    LucGamesDE Baby Zombie

    Messages:
    170
    You didn't understand my problem... I only want to set the nametag for $player! But $player1 sees the nametag "Text1" and $player2 sees "Text2"
     
  10. Intyre

    Intyre Administrator Staff Member PMMP Team

    Messages:
    81
    GitHub:
    Intyre
    @jasonwynn10 see! :p
     
  11. LucGamesDE

    LucGamesDE Baby Zombie

    Messages:
    170
    Now u should know my problem :p

    Or do u need more information?
     
  12. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    Okay, so you are asking for the needed code to make a player's nametag appear differently to different players?
     
  13. LucGamesDE

    LucGamesDE Baby Zombie

    Messages:
    170
    Yes :)
     
  14. LucGamesDE

    LucGamesDE Baby Zombie

    Messages:
    170
    Any idea?
     
  15. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    PHP:
    $pk = new \pocketmine\network\mcpe\protocol\SetEntityDataPacket();
    $pk->entityRuntimeId $player1->getId();
    $pk->metadata = [
        \
    pocketmine\entity\Entity::DATA_NAMETAG => [\pocketmine\entity\Entity::DATA_TYPE_STRING"player1 new name"]
    ];
    $player2->dataPacket($pk);
     
    Last edited: Jul 4, 2017
  16. LucGamesDE

    LucGamesDE Baby Zombie

    Messages:
    170
    This doesn't work for players.
     
  17. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    why wouldn't it? PocketMine uses it when setting a player's data for the first time anyway.
     
  18. LucGamesDE

    LucGamesDE Baby Zombie

    Messages:
    170
    How can I find this in the PM code?
     
  19. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    Entity.php line 233
    the data is send to players in a packet on line 867
     
  20. LucGamesDE

    LucGamesDE Baby Zombie

    Messages:
    170
    It isn't working for me. Is there another way?
     
  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.