How can I make a player kill a member of his team have effects? can you help me. Here is my code! public function onDeathEffect(PlayerDeathEvent $event){ $jugador = $event->getEntity(); $mapa = $jugador->getLevel()->getFolderName(); if(in_array($mapa,$this->arenas)) { $event->setDeathMessage(""); if($event->getEntity()->getLastDamageCause() instanceof EntityDamageByEntityEvent) { $asassin = $event->getEntity()->getLastDamageCause()->getDamager(); $config = new Config($this->getDataFolder() . "/config.yml", Config::YAML); if($config->get($mapa . "PlayTime") != null) { if($config->get($mapa . "PlayTime") > 779) { $event->setCancelled(); } if ((strpos($jugador->getNameTag(), "§l§6ANONYMAUS") !== false) && (strpos($event->getDamager()->getNameTag(), "§l§6ANONYMAUS") !== false)) { $event->setCancelled(); $asassin->sendMessage("§aHas Matado A Un Inocente"); $nause = Effect::getEffect(9); $natus = Effect::getEffect(18); $nause->setVisible(true); $natus->setVisible(true); $nause->setAmplifier(1); $natus->setAmplifier(1); $nause->setDuration(100); $natus->setDuration(100); $asassin->addEffect($nause); $asassin->addEffect($natus); $assassin->getInventory()->clearAll(); } elseif ((strpos($jugador->getNameTag(), "§f§l§6ANONYMAUS§f§6") !== false) && (strpos($event->getDamager()->getNameTag(), "§f§l§6ANONYMAUS§f§6") !== false)) { $event->setCancelled(); } } } } }
So do you want an effect that plays when a player teamkills their teammate? We need to know How do you define teams first though
Ok here ill do it for you: Give me some time to properly organise and read your code then ill try and see what i can do PHP: public function onDeathEffect(PlayerDeathEvent $event){$jugador = $event->getEntity();$mapa = $jugador->getLevel()->getFolderName();if(in_array($mapa,$this->arenas)){$event->setDeathMessage("");if($event->getEntity()->getLastDamageCause() instanceof EntityDamageByEntityEvent){$asassin = $event->getEntity()->getLastDamageCause()->getDamager();$config = new Config($this->getDataFolder() . "/config.yml", Config::YAML);if($config->get($mapa . "PlayTime") != null){if($config->get($mapa . "PlayTime") > 779){$event->setCancelled();}if ((strpos($jugador->getNameTag(), "§l§6ANONYMAUS") !== false) && (strpos($event->getDamager()->getNameTag(), "§l§6ANONYMAUS") !== false)) {$event->setCancelled();$asassin->sendMessage("§aHas Matado A Un Inocente");$nause = Effect::getEffect(9);$natus = Effect::getEffect(18);$nause->setVisible(true);$natus->setVisible(true);$nause->setAmplifier(1);$natus->setAmplifier(1);$nause->setDuration(100);$natus->setDuration(100);$asassin->addEffect($nause);$asassin->addEffect($natus);$assassin->getInventory()->clearAll();}elseif ((strpos($jugador->getNameTag(), "§f§l§6ANONYMAUS§f§6") !== false) && (strpos($event->getDamager()->getNameTag(), "§f§l§6ANONYMAUS§f§6") !== false)) {$event->setCancelled();} } } } } Edit: Oh crap its spanish this will take some time