Hi How can i give a Player a Potion. That Code here doesn't Work: PHP: $sender->getInventory()->addItem(Item::get(373:8225 , 0, 1)); Or isn't it possible?
PocketMine does not support potions. Also, use Code: Item::get(Item::POTION, 8225, 1) PHP does not accept colons.
Potion's data values in mcpe are different from those in PC version. This will help you. https://github.com/iTXTech/Genisys/blob/master/src/pocketmine/item/Potion.php So the id of Potion of Regeneration II is 373:30.
My Method ist that : PHP: $item = Item::ITEM_NAME ;$player = $event->getPlayer();$player->getInventory()->addItem($item); i hope i helped you
Please learn to use the PocketMine API before you try to help people. You're passing an integer to addItem() which only takes Item objects. Furthermore, I think the previous posts already addresses the issue...
PHP: $sender->getInventory()->addItem(Item::get(373, 8225, 1)); or PHP: $sender->getInventory()->addItem(Item::get(ITEM::ITEMNAME));
Item::NAME will return the Item ID, so it is basically the same. But, what you have to watch out for, is the damage. (second parameter). Each potion has a different one, but the same Item ID.
It is not wrong. https://github.com/PocketMine/Pocke...c/pocketmine/inventory/BaseInventory.php#L251 Note that ITEM::ITEMNAME is also incorrect syntax as PHP is case-sensitive. You should be generally be using the constants instead of the Item IDs in the event that the IDs may change.