register events onEnable using this code PHP: $this->getServer()->getPluginManager()->registerEvents($this, $this); and you forgot to Code: use pocketmine\event\Listener; and then class Main must imeplent Listener.php
@Zayd Try PHP: $this->getLogger()->info(); instead of PHP: $this->getLogger->info(); Edit: Nevermind, you meant the message on EntityDamageEvent.
An import is the same as a use statement. You forgot to add a use statement for EntityDamageByEntityEvent.
Of course you need to define $entity. Every variable mst be defined before using it. To get the entity it'd be $event->getEntity(), but in your case you should use $event->getEntity()->getNameTag().
LMFAO. Sorry @SalmonDE + @corytortoise i misread and imported EntityDamageEvent, not EntityByEntityDamageEvent! . I'm also going to define the variable now.. However @Sandertv instead of getNameTag() shouldn't I use getName()?
PHP: <?phpnamespace ZaydPE;use pocketmine\plugin\PluginBase;use pocketmine\event\entity\EntityDamageEvent;use pocketmine\event\entity\EntityDamageByEvent;use pocketmine\utils\TextFormat;use pocketmine\event\Listener;class Main extends PluginBase implements Listener{public function onEnable(){ $this->getLogger()->info("HealthMessage enabled!"); $this->getServer()->getPluginManager()->registerEvents($this, $this);}public function onDisable(){ $this->getLogger()->info("HealthMessage disabled!"); $this->getServer()->getPluginManager()->registerEvents($this, $this);}public function onDamage(EntityDamageEvent $e){if($e instanceof EntityDamageByEntityEvent){$damager = $e->getDamager();$health = $e->getEntity()->getHealth();$entity = $e->getEntity()->getNameTag();$maxHealth = $entity->getMaxHealth();$damager->sendMessage(TextFormat::GREEN ."$entity is on $health/$maxHealth HP! "); } }} Have i done something wrong here whilst trying to define $entity...? As it still doesn't work.
You are calling $maxhealth on string, not on Entity. Use $maxhealth = $e->getEntity()->getMaxHealth();
You could use a task or you could save the timestamp and wait until the timestamp is n seconds higher than it was before. That's what I can think of right now.