Nothing executed

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

  1. JarguarLoveMC

    JarguarLoveMC Silverfish

    Messages:
    23
    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 Silverfish

    Messages:
    18
    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 Silverfish

    Messages:
    23
    that?
     
  4. Destroyer57

    Destroyer57 Baby Zombie

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

    wolfdale Baby Zombie

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

    JarguarLoveMC Silverfish

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

    Emirhan Akpınar Silverfish

    Messages:
    18
    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");

          }

        }

      }

    }
     
  8. Emirhan Akpınar

    Emirhan Akpınar Silverfish

    Messages:
    18
    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.