I can't really explain it any simpler. You used item::get(), try Item::get with an uppercase I in place of it.
$player->getInventory()->sendContents($player->getInventory()); add that after you give the player the head. Sometimes custom named items or items with custom metas don't show in the inventory.
It doesn't give me the head after I killed the player And it didn't send me the message too. PHP: public function onDeath(PlayerDeathEvent $ev){ $player = $ev->getPlayer(); $cause = $player->getLastDamageCause(); if($cause instanceof EntityDamageByEntityEvent){ $damager = $cause->getDamager(); $inv = $damager->getInventory(); $head = Item::get(397,0,1); $name = $damager->getName(); $head->setCustomName("$name's Head"); $inv->addItem($head); $damager->getInventory()->sendContents($damager->getInventory()); $damager->sendMessage("you got $name's Head"); }}
I think the $damager is not registering as a player I've tried PHP: $p = $damager->getPlayer(); But no luck
Umm tr add if damager is instance of player PHP: public function onDeath(PlayerDeathEvent $ev){ $player = $ev->getPlayer(); $cause = $player->getLastDamageCause(); if($cause instanceof EntityDamageByEntityEvent){ $damager = $cause->getDamager(); if($damager instanceof Player){ $inv = $damager->getInventory(); $head = Item::get(397,0,1); $name = $damager->getName(); $head->setCustomName("$name's Head"); $inv->addItem($head); $damager->getInventory()->sendContents($damager->getInventory()); $damager->sendMessage("you got $name's Head"); }}}
This is my overall code Still doesn't give me the head PHP: use pocketmine\Server;use pocketmine\Player;use pocketmine\event\player\PlayerDeathEvent;use pocketmine\event\Listener;use pocketmine\plugin\PluginBase;use pocketmine\item\Item;use pocketmine\entity\Entity;class Main extends PluginBase implements Listener{ public function onEnable(){ $this->getServer()->getPluginManager()->registerEvents($this,$this); } public function onDeath(PlayerDeathEvent $ev){ $player = $ev->getPlayer(); $cause = $player->getLastDamageCause(); if($cause instanceof EntityDamageByEntityEvent){ $damager = $cause->getDamager(); if($damager instanceof Player){ $inv = $damager->getInventory(); $head = Item::get(397,0,1); $name = $damager->getName(); $head->setCustomName("$name's Head"); $inv->addItem($head); $damager->getInventory()->sendContents($damager->getInventory()); $damager->sendMessage("you got $name's Head"); }}} public function onDisable(){ $this->getLogger()->Info("Offline"); }}
Also from your code.. it looks like youre giving the killer's head back to the killer.. and yea add EntityDamageByEntityEvent class.
Ye I've fix that it gives the head now but how can I get the Steve head instead of skeleton head Do I just need to do 937:3?