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

Can i get the skin from a online user?

Discussion in 'Development' started by LewBr, Oct 3, 2017.

  1. LewBr

    LewBr Zombie

    Messages:
    385
    GitHub:
    lewbr
    Hello, sorry for my bad english, i have a question about the Packet AddPlayer, i want to get the $pk->skin or $pk->skinID of a user that is online example: if($player->getName()->isOnline){ etc.. and if the user is offline i want to set the player skinID to Alex or Steve.

    Please H-HELP!
     
    Last edited: Oct 3, 2017
    MasterPE likes this.
  2. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    You can just use $player->getSkin() in PlayerJoinEvent.
     
  3. LewBr

    LewBr Zombie

    Messages:
    385
    GitHub:
    lewbr
    I don't really want the skin from any user i just want to spawn a player entity that is on scoreboard of my server, and i have all thing finish but the skin not.. i want to spawn a player entity whit the skin of the player on the TopPlayers understand? (sorry best english)
     
    MasterPE likes this.
  4. themestl

    themestl Spider Jockey

    Messages:
    39
    GitHub:
    themestl
    $nbt = Server::getInstance()->getOfflinePlayerData('puts nickname here');
    $entityOfYourTopPlayersScoreboardOrWhatAreYouWanted->setSkin($nbt->Skin->Data, $nbt->Skin->Name);
    Do you mean this?
     
  5. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    The new Skin API makes it easier.
    PHP:
    /** @var Player $topPlayer */
    ScoreboardEntity->setSkin($topPlayer->getSkin());
    Don't forget to call ScoreboardEntity::sendSkin() o/

    This API is only available in latest ALPHA9 development builds!
     
    Last edited: Oct 3, 2017
  6. dktapps

    dktapps Administrator Staff Member PMMP Team

    Messages:
    774
    GitHub:
    dktapps
    should be mentioned that this API is only available in latest ALPHA9 development builds.
     
    jasonwynn10 likes this.
  7. LewBr

    LewBr Zombie

    Messages:
    385
    GitHub:
    lewbr
    I mean on $pk on AddPlayerPacket..?
     
    MasterPE likes this.
  8. themestl

    themestl Spider Jockey

    Messages:
    39
    GitHub:
    themestl
    Nol i can't do it with this packet for this. Try PlayerListPacket
     
  9. LewBr

    LewBr Zombie

    Messages:
    385
    GitHub:
    lewbr
    Can you give me an example what should i do on $pk->skin whit this PlayerListPacket? I want to get skin from other player that is on Ranking.
    I have see the packet and i don't now how to do that whit
    PHP:
    $pk->skin = new Skin(
                        
    $this->getString(), //id
                        
    $this->getString(), //data
                        
    $this->getString(), //cape
                        
    $this->getString(), //geometry name
                        
    $this->getString() //geometry data
                    
    );
     
    MasterPE likes this.
  10. themestl

    themestl Spider Jockey

    Messages:
    39
    GitHub:
    themestl
    Yes, I can. Try it:
    PHP:
    $pk->skin = new Skin($nbt->Skin->Data$nbt->Skin->Name);
     
    MasterPE likes this.
  11. LewBr

    LewBr Zombie

    Messages:
    385
    GitHub:
    lewbr
    Oh, but i won't to use $nbt i just use Packets like $pk, too for AddPlayerPacket.
    And have you an example whit nickname of others? I need to set?
     
    MasterPE likes this.
  12. LewBr

    LewBr Zombie

    Messages:
    385
    GitHub:
    lewbr
    Don't have any NBT on my plugin.
    srry my english.
     
    MasterPE likes this.
  13. themestl

    themestl Spider Jockey

    Messages:
    39
    GitHub:
    themestl
    $nbt = Server::getInstance()->getOfflinePlayerData('puts nickname here');
     
    MasterPE likes this.
  14. LewBr

    LewBr Zombie

    Messages:
    385
    GitHub:
    lewbr
    I have this error whit CompoundTag
    Could not execute task leohardu\LeoHarduEntidade\Textos: Undefined property: pocketmine\nbt\tag\CompoundTag::$Skin

    Code
    PHP:
    $pk->skin = new Skin($nbt->Skin->Data$nbt->Skin->Name);
     
  15. themestl

    themestl Spider Jockey

    Messages:
    39
    GitHub:
    themestl
    Hmmm. Try to use var_dump($nbt); and look for skin
     
  16. themestl

    themestl Spider Jockey

    Messages:
    39
    GitHub:
    themestl
    Maybe PMMP remove Skin from nbt.
     
  17. LewBr

    LewBr Zombie

    Messages:
    385
    GitHub:
    lewbr
    I think PlayerSkinPacket is better for this, but i don't know how to get skin from other player and set to this packet.
     
  18. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    If you're on API 3.0.0-ALPHA9
    PHP:
    $packet = new PlayerSkinPacket();
    $packet->skin $somePlayer->getSkin();
     
  19. LewBr

    LewBr Zombie

    Messages:
    385
    GitHub:
    lewbr
    In $somePlayer what i need to do? $somePlayer = $p->getName() == "NICK";
    This works?
     
  20. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    That would set $somePlayer to a boolean value, and as you probably already know, or should be knowing.. types in PHP don't have any callable functions like java does. They aren't even considered to be classes. getSkin() is a PocketMine API function and has nothing to do with PHP. Search PMMP for "getSkin" and find out what $somePlayer should be so as to call $somePlayer->getSkin() ;)
     
    jasonwynn10 and HimbeersaftLP like this.
  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.