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

Armor Issues

Discussion in 'Development' started by FunnyBuddys, Aug 31, 2018.

  1. FunnyBuddys

    FunnyBuddys Spider

    Messages:
    14
    GitHub:
    FunnyBuddys
    hello

    I used "getArmorInventory->setBoots" to put shoes on a player when they entered the server.

    Problem is, players who are already on it don't see these boots. Only the people who enter the server afterwards will see the boots of the respective player.

    The whole thing can be reproduced on with trousers, breastplates and helmets
    PHP:
    if($player->hasPermission("lobby.yt")){
        
    /** @var Armor $lila */
        
    $lila Armor::get(Armor::LEATHER_BOOTS);
        
    $lila->setCustomColor(new \pocketmine\utils\Color(1620255));
        
    $player->getArmorInventory()->setBoots($lila);
          }
    I hope you have some advice for me.
     
  2. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    In which event did you call the code? Or was it outside events?
     
  3. FunnyBuddys

    FunnyBuddys Spider

    Messages:
    14
    GitHub:
    FunnyBuddys
    I used the PlayerJoinEvent
     
  4. Angel

    Angel Spider Jockey

    Messages:
    44
    GitHub:
    aimjel
    From what I tested a couple of weeks ago, PlayerJoinEvent isn't always or at all called when the player joins or is spawned in the server where he can move.
     
  5. SleepSpace9

    SleepSpace9 Slime

    Messages:
    78
    GitHub:
    sleepspace9
    You may try using ArmorInventory::sendContents() or if it also doesn't work give the boots in a delayed task.
     
  6. Primus

    Primus Zombie Pigman

    Messages:
    749
    try PlayerRespawnEvent?
     
  7. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    sendContents() wouldn't work because at the time PlayerJoinEvent gets called, other players still can't see the player so the player has 0 viewers. A delayed task would work, yeah.
    It no longer gets called on player joins anymore AFAIK. There were other events that would be unwantedly called on player joins that no longer do (eg: EntityArmorChangeEvent).
     
    xXNiceAssassinlo YT likes this.
  8. Primus

    Primus Zombie Pigman

    Messages:
    749
    It would be great if the event got called twice, like second time after one tick.
     
  9. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
  10. Primus

    Primus Zombie Pigman

    Messages:
    749
  11. AkmalFairuz

    AkmalFairuz Spider Jockey

    Messages:
    25
    GitHub:
    akmalfairuz
    Try this code
    PHP:

    use pocketmine\item\Item;
    use 
    pocketmine\utils\Color;

    PHP:
    if($player->hasPermission("lobby.yt")){
            
    $armor Item::get(Item::LEATHER_BOOTS);
            
    $color = new Color(02040);
            
    $armor->setCustomColor($color);
            
    $player->getArmorInventory()->setBoots($armor);
    }
     
  12. Primus

    Primus Zombie Pigman

    Messages:
    749
    This code will cause same problems, players around (viewers) won't get your armor contents updated!
     
    OnTheVerge and Muqsit like this.
  13. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    He has to $player->sendContents($player->getViewers());
    Right?
     
  14. FunnyBuddys

    FunnyBuddys Spider

    Messages:
    14
    GitHub:
    FunnyBuddys
    No, as @Muqsit already said, while entering you don't see the respective player so the viewers are equal to 0
     
  15. Primus

    Primus Zombie Pigman

    Messages:
    749
    Perhaps you can pass "viewers" yourself, like get all players in the world.
     
  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.