I want players to get a full diamond armor when they join PHP: public function onJoin(PlayerJoinEvent $event){ $player = $event->getPlayer(); $name = $event->getPlayer()->getName(); $player->sendMessage($this->getConfig()->get("join-message")); $player->setArmor(Item::get(Item::DIAMOND_CHESTPLATE)); }
heres more help just incase, https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/inventory/PlayerInventory.php#L278
PHP: $player->getInventory()->setHelmet(Item::get(Item::DIAMOND_HELMET)); $player->getInventory()->setChestplate(Item::get(Item::DIAMOND_CHESTPLATE));$player->getInventory()->setLeggings(Item::get(Item::DIAMOND_LEGGINGS)); $player->getInventory()->setBoots(Item::get(Item::DIAMOND_BOOTS));
[Server thread/CRITICAL]: Error: "Call to undefined method pocketmine\inventory\PlayerInventory::sendArmorContents()" (EXCEPTION) in "plugins/LobbyCore/src/Superomarking/LobbyCore/Main" at line 396
public function __construct(Living $holder){ $this->holder = $holder; parent::__construct(); } public function getHolder() : Living{ return $this->holder; } public function getName() : string{ return "Armor"; } public function getDefaultSize() : int{ return 4; } public function getHelmet() : Item{ return $this->getItem(self::SLOT_HEAD); } public function getChestplate() : Item{ return $this->getItem(self::SLOT_CHEST); } public function getLeggings() : Item{ return $this->getItem(self::SLOT_LEGS); } public function getBoots() : Item{ return $this->getItem(self::SLOT_FEET); } public function setHelmet(Item $helmet) : bool{ return $this->setItem(self::SLOT_HEAD, $helmet); } public function setChestplate(Item $chestplate) : bool{ return $this->setItem(self::SLOT_CHEST, $chestplate); } public function setLeggings(Item $leggings) : bool{ return $this->setItem(self::SLOT_LEGS, $leggings); } public function setBoots(Item $boots) : bool{ return $this->setItem(self::SLOT_FEET, $boots); } public function sendSlot(int $index, $target) : void{ if($target instanceof Player){ $target = [$target]; } $pk = new MobArmorEquipmentPacket(); $pk->entityRuntimeId = $this->getHolder()->getId(); $pk->head = $this->getHelmet(); $pk->chest = $this->getChestplate(); $pk->legs = $this->getLeggings(); $pk->feet = $this->getBoots(); $pk->encode(); foreach($target as $player){ if($player === $this->getHolder()){ /** @var Player $player */ $pk2 = new InventorySlotPacket(); $pk2->windowId = $player->getWindowId($this); $pk2->inventorySlot = $index; $pk2->item = ItemStackWrapper::legacy($this->getItem($index)); $player->dataPacket($pk2); }else{ $player->dataPacket($pk); } } } public function sendContents($target) : void{ if($target instanceof Player){ $target = [$target]; } $pk = new MobArmorEquipmentPacket(); $pk->entityRuntimeId = $this->getHolder()->getId(); $pk->head = $this->getHelmet(); $pk->chest = $this->getChestplate(); $pk->legs = $this->getLeggings(); $pk->feet = $this->getBoots(); $pk->encode(); foreach($target as $player){ if($player === $this->getHolder()){ $pk2 = new InventoryContentPacket(); $pk2->windowId = $player->getWindowId($this); $pk2->items = array_map([ItemStackWrapper::class, 'legacy'], $this->getContents(true)); $player->dataPacket($pk2); }else{ $player->dataPacket($pk); } } } /** * @return Player[] */ public function getViewers() : array{ return array_merge(parent::getViewers(), $this->holder->getViewers()); } } this is in the pocketmine armor inventory
The sendArmorContents() doesn't even exist. Do more research before giving a wrong answer? The inventory and armor slots' been separated a while ago. An alternative would be PHP: $player->getArmorInventory()->setContents($items); Edit: Noticed that the thread was from 3 years ago. Honestly, @Superomarking. Make a new thread instead of bumping old threads by bringing up an outdated code. It causes confusions(at least for me)