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

How to clear a players Armor inventory?

Discussion in 'Development' started by Kabluinc, Apr 5, 2018.

  1. Kabluinc

    Kabluinc Baby Zombie

    Messages:
    129
    Hi, i am trying to make it so that when a player switches worlds, their armor is cleared. As currently when a player is switching worlds, forexample from a creative world to a survival one, they can take their armor with them.

    What i have tried so far:

    PHP:
    $player->getInventory()->clearAll()
    PHP:
    $player->getInventory()->setContents([]);
    Neither of those have helped. A players inventory is cleared but not their armor.
     
  2. Alair069

    Alair069 Spider

    Messages:
    12
    GitHub:
    Alair069
    $player->getArmorInventory()->clearAll();
     
    DaisukeDaisuke and Kabluinc like this.
  3. Kabluinc

    Kabluinc Baby Zombie

    Messages:
    129
    Thanks, that worked :)
     
  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.