EntityDamageByEntityEvent Check if the health of the damaged entity minus the final health is <= 0 If so, check if the damager is a player. Then $event->getDamager()->getInventory()->addItem(Item::get(3, 0, 1));
because i'm tryna make it when you kill a zombie you get a certain reward and when killing another mob you get another reward
Have you listened to events before? If so, listen to EntityDeathEvent and check if the entity is a zombie. If it is, check if Zombie->getLastDamageCause() is an instanceof EntityDamageByEntityEvent and whether the damager is an instanceof Player.
Btw, don't forget to import the correct class namespaces. PHP doesn't throw errors when a class doesn't exist while doing an instanceof check for object instanceof class.
correct me if i'm wrong if($cause instanceof EntityDeathEvent){ $damager = $cause->getDamager(); if($damager instanceof Player){
public function onDeath(EntityDeathEvent $ev){ $cause = $player->getLastDamageCause(); if($cause instanceof EntityDamageByEntityEvent){ $damager = IronGolem->getLastDamageCause() if($damager instanceof Player){ $inv = $damager->getInventory(); $IGHead = Item::get(397,0,1); $name = $player->getName(); $IGHead->setCustomName(TF:: DARK_PURPLE . "Iron Golem Head")); $inv->addItem($IGead);
You missed a lot of } and $player is undefined EDIT: Use the insert code button and select the PHP so the code would be readable by us.