Hello Coder, I was searching a methode to get the killer of a player. I saw something in the src code on Pocketmine but dont understand that. If i take the EntityDamageByEntityEvent i only can get the damager where the normal player is alive. But i want to get the damager and normal player where the normal player got killed by the damger (sorry for bad description) -Sensej
Yes Thank you but i think you forgot to get the name PHP: public function onDeath(EntityDeathEvent $event){ $entity = $event->getEntity(); $cause = $entity->getLastDamageCause(); //get the last damage cause if($cause instanceof EntityDamageByEntityEvent){ //if the cause is by an another entity $killer = $cause->getDamager(); //gets the event damager if($killer instanceof Player){ $entity->sendMessage($killer->getName()." is your killer"); //;) } } }
Nope. The Output would be Player(1) or player(2...) Sensej is rigth you have to use getName() if you want the Player Name