Inglish message: In PlayerDamageEvent how can I get the player that gave the damage, and the player that took the damage?
There is no PlayerDamageEvent. There is, however, EntityDamageEvent, and EntityDamageByEntityEvent, which can be used as you describe. After you have checked if the event is an instance of EntityDamageByEntityEvent, you can use $event->getDamager() and $event->getEntity() to find the desired information. The Damager is the Entity that gave the damage, and the Entity is the Entity that took the damage. Keep in mind that you will also need to check if the Entity and the Damager are both Players, if you only want to listen for the event that one Player damages another. For more info, or to fact check me(I may very well be wrong), check out the source file here.
PHP: public function onDamage(pocketmine\event\entity\EntityDamageEvent $event) { if($event instanceof pocketmine\event\entity\EntityDamageByEntityEvent) { $victim = $event->getEntity(); if($victim instanceof pocketmine\Player) { $attacker = $event->getDamager(); // Do stuff here } }} Please refrain from using other languages on this forum; this in an English forum, not an international one. Why bother spamming the thread with information that is easily readily accessible within said thread?
Anyone else notice that English is spelled with an 'I' ? lol Also, this topic has been discussed many times. This needs to be moved to the facepalm section.
all bad questions should be answered, why? Because the people get no answer at other sites lol we should help all who want to learn something ^^ its my opinion xD