The last 4 slots of the inventory of a player is the armor. getItem($index) and setItem($index, $item) in the inventory would work, but in order to get the index you will need to get the total slots of the normal inventory first. This can be done with getSize() and add 0-3 to it, but pocketmine has a function build in that does this for you: getArmorItem($index) and setArmorItem($index, $item). The index in these functions can be 0-3. Index 0 is the slot of the boots, 1 is the slot of the legging, 2 is the slot of the chestplate and 3 is the slot of the helmet. But if you don't want to remember these indexes, you can use the following functions: getBoots()/setBoots($item) getLeggings()/setLeggings($item) getChestplate()/setChestplate($item) getHelmet()/setHelmet($item) For example if I want to give a player full diamond armor you can use this code: Code: $player = $this->getServer()->getPlayer("Steve"); $player->inventory->setBoots(new Item(313, 0, 1)); $player->inventory->setLeggings(new Item(312, 0, 1)); $player->inventory->setChestplate(new Item(311, 0, 1)); $player->inventory->setHelmet(new Item(310, 0, 1));
I think it is actually PHP: $player = $this->getServer()->getPlayer("Steve");$player->getInventory()->setHelmet(Item::get(item id));$player->getInventory()->setChestplate(Item::get(item id));$player->getInventory()->setLeggings(Item::get(item id));$player->getInventory()->setBoots(Item::get(item id));$player->getInventory()->sendArmorContents($player);//OR$items = array(Item::get(id of helmet),Item::get(id of chestplate),Item::get(id of leggings),Item::get(id of boots));$player = $this->getServer()->getPlayer("Steve");$player->getInventory()->setArmorContents($items);$player->getInventoey()->sendArmorContents($player);
I'm not sure, but I think the variable $inventory is public, so you can use it directly Edit Sorry you're right, $inventory is protected so you can only get it with getInventory()
Yeah, it makes complex plugins far easier. Especially because you don't need all the code on one file.
The new API is a lot of fun There's lots of stuff to learn, and the docs are really helpful in plugin making. I usually don't answer things because I'm not too familiar with it yet, and don't want to embarrass myself, but I learn a lot from reading peoples' responses as well.