So I am trying to make something happen when a player is killed by another player. The code works, except the server crashes f the player is killed by a block, fire, TNT etc. The code looks something like PHP: Public function playerDeath(PlayerDeathEvent $event) {$victim = $event->getEntity();$cause = $victim->getLastDamageCause();$killer = $cause->getDamager();if($killer instanceof Player) {//Blah blah;}} The console gives an error message saying "Call to undefined function EntityDamageEvent::getDamager()" Any tips or suggestions?
I'm still getting Code: Fatal error: Call to undefined method pocketmine\event\entity\EntityDamageEvent::getDamager() for line 4
You did it wrong, PHP: public function onDeath(PlayerDeathEvent $event) { $victim = $event->getEntity(); $c = $victim->getLastDamageCause(); if($c instanceof EntityDamageByEntityEvent) { $killer = $c->getDamager(); //Your stuff goes here }}