1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Effects when killing a partner

Discussion in 'Development' started by TGames, Dec 18, 2017.

  1. TGames

    TGames Silverfish

    Messages:
    18
    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();
    } } } } }
     
  2. Karanpatel567

    Karanpatel567 Baby Zombie

    Messages:
    115
    GitHub:
    Karanpatel567
    Elaborate please! :)
     
  3. Indexfire

    Indexfire Baby Zombie

    Messages:
    137
    GitHub:
    Indexfire
    Use PHP tags to format code, i can barely read what is in there :/
     
  4. Derpific

    Derpific Spider Jockey

    Messages:
    44
    GitHub:
    Derpific
    Yeah, they are there for a reason :p
     
    OnTheVerge likes this.
  5. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    if you have nothing helpful for OP you might as well not say it,
     
    Levi, SOFe and EdwardHamHam like this.
  6. Indexfire

    Indexfire Baby Zombie

    Messages:
    137
    GitHub:
    Indexfire
    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
     
  7. Indexfire

    Indexfire Baby Zombie

    Messages:
    137
    GitHub:
    Indexfire
    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
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.