No errors, just won't work. I want it to announce how many pots the player has left on killing event. PHP: <?phpnamespace HMR;use pocketmine\plugin\PluginBase;use pocketmine\event\Listener;use pocketmine\utils\TextFormat;use pocketmine\event\player\PlayerDeathEvent;use pocketmine\event\entity\EntityDamageByEntityEvent;use pocketmine\Player;use pocketmine\Server;use pocketmine\math\Vector3;use pocketmine\command\ConsoleCommandSender;class Main extends PluginBase implements Listener{ public function onEnable() { $this->getServer()->getPluginManager()->registerEvents($this,$this); $this->getLogger()->info(TextFormat::BLUE . "HealthMessageReturn Enabled!"); } public function onDeath(PlayerDeathEvent $event) { $cause = $event->getEntity()->getLastDamageCause(); if($cause instanceof EntityDamageByEntityEvent) { $player = $event->getEntity(); $killer = $event->getEntity()->getLastDamageCause()->getDamager(); if($killer instanceof $player){ $item = $killer->getInventory()->getContents(); $itemId = $item->getId(); if ($itemId === "438:22") { $count = $item->getCount(); $this->getServer()->dispatchCommand(new ConsoleCommandSender(), "sm * §4".$player->getName()." §r§chas been annihilated by the one and only§4 ".$killer->getName()."§4[❤ ".$killer->getHealth()." HP - ".$count." Pots]§r§c."); } } } } }}
I'm sure you can find an example without any help... Just loop through the array and count how many items have the ID.