Hello, Today I'm wondering how to set an item given to the player into a given slot on the players hotbar. I know already how to add items into the players inventory, just not how to get the slot on the hot bar. I think it has to do with this function, PHP: use pocketmine/inventory/PlayerInventory;setHotbarSlotIndex() But I'm not sure how to implement it. Any feedback is appreciated, -Calrizer
PHP: $human->getInventory()->setHotbatSlotIndex(); There's no need(/way) to implement it, it is a function.
No I think theres some confusion. Heres my real life example: I'm trying to give the player 'Item A' into the first slot and 'Item B' into the second.
So I've been doing a few tests of this and I still can't get it to work, heres my code: PHP: $items = [ Item::get(332, 0, 1), Item::get(267, 0, 1) ];$p->getInventory()->addItem($items[0]);$p->getInventory()->addItem($items[1]);$p->getInventory()->setHotbarSlotIndex(332, 1);$p->getInventory()->setHotbarSlotIndex(267, 2); Can any of you see something obviously wrong with it and maybe find a solution.
It is Inventory::setHotbarSlotIndex($index, $slot); so $index is the slot in the inventory, not the item id