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

Solved Set armour

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

  1. RyanShaw

    RyanShaw Witch

    Messages:
    69
    Hello, ive been messing around with a few things but i just cant seem to get this to work,
    PHP:
            $chestPlate Item::get(299);
            
    $sender->getInventory()->setChestplate($chestPlate); 
    But i keep getting this error

    05.04 22:07:57 [Server] Server thread/DEBUG #1 src/pocketmine/command/SimpleCommandMap(258): pocketmine\command\PluginCommand->execute(pocketmine\Player object, string upgrade, array Array()) 05.04 22:07:57 [Server] Server thread/DEBUG #0 src/pocketmine/command/PluginCommand(58): Evan\Upgrades\Main->onCommand(pocketmine\Player object, pocketmine\command\PluginCommand object, string upgrade, array Array()) 05.04 22:07:57 [Server] Server thread/CRITICAL Error: "Call to undefined method pocketmine\inventory\PlayerInventory::setChestplate()" (EXCEPTION) in "Upgrades/src/Evan/Upgrades/Main" at line 24 05.04 22:07:57 [Server] Server thread/CRITICAL Unhandled exception executing command 'upgrade' in upgrade: Call to undefined method pocketmine\inventory\PlayerInventory::setChestplate()

    Any suggestions anyone? Ive found old threads on how to do this but their answers wont work either :confused:
     
  2. SleepSpace9

    SleepSpace9 Slime

    Messages:
    78
    GitHub:
    sleepspace9
    You have to use getArmorInventory():
    PHP:
    $chestPlate Item::get(299);
    $sender->getArmorInventory()->setChestplate($chestPlate);
     
    RyanShaw likes this.
  3. RyanShaw

    RyanShaw Witch

    Messages:
    69
    Ty :p
     
  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.