Nothing executed

Discussion in 'Development' started by JarguarLoveMC, Jan 4, 2019.

  1. JarguarLoveMC

    JarguarLoveMC Spider Jockey

    Messages:
    26
    I'm trying to make it so if player wear diamond chestplate and died it will send "L" as a message to the killer but nothing happened

    public function onDeath(PlayerDeathEvent $event){

    if($event->getEntity()->getLastDamageCause() instanceof EntityDamageByEntityEvent){
    $killer = $event->getEntity()->getLastDamageCause()->getDamager();
    $dead = $event->getEntity();

    if($killer instanceof Player && $dead instanceof Player){

    if($dead->getArmorInventory()->getChestplate());
    $killer->sendMessage(TF::BOLD . TF::DARK_AQUA . "+L");
    }
    }
    }

    i think i'm missing something?
     
  2. Emirhan Akpınar

    Emirhan Akpınar Spider Jockey

    Messages:
    43
    GitHub:
    EmirhanWSD
    PHP:
    if($dead->getArmorInventory()->getChestplate()->getId() == Item::DIAMOND_CHESTPLATE) {
     
    $killer->sendMessage(TF::BOLD TF::DARK_AQUA "+L");

    }
     
    wolfdale likes this.
  3. JarguarLoveMC

    JarguarLoveMC Spider Jockey

    Messages:
    26
    that?
     
  4. Destroyer57

    Destroyer57 Zombie

    Messages:
    220
    yea because your last if statement doesnt return a boolean
     
  5. wolfdale

    wolfdale Zombie

    Messages:
    297
    First, did you register events?
    Then did you use \pocketmine\event\entity\EntityDamageByEntityEvent and \pocketmine\Player?
     
  6. JarguarLoveMC

    JarguarLoveMC Spider Jockey

    Messages:
    26
    yes i did
     
  7. Emirhan Akpınar

    Emirhan Akpınar Spider Jockey

    Messages:
    43
    GitHub:
    EmirhanWSD
    PHP:
    public function onDeath(PlayerDeathEvent $event) {
      
    $player $event->getPlayer();
      
    $lastDamageCause $player->getLastDamageCause();
      if(
    $lastDamageCause instanceof EntityDamageByEntityEvent) {
        
    $killer $lastDamageCause->getDamager();
        if(
    $killer instanceof Player) {
          if(
    $player->getArmorInventory()->getChestplate()->getId() == Item::DIAMOND_CHESTPLATE) {
            
    $killer->sendMessage("+L");

          }

        }

      }

    }
     
    JarguarLoveMC likes this.
  8. Emirhan Akpınar

    Emirhan Akpınar Spider Jockey

    Messages:
    43
    GitHub:
    EmirhanWSD
    Its true. You can try.
     

Share This Page

  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.