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

How can i detect when a player is using some armor?

Discussion in 'Development' started by LewBr, Apr 23, 2018.

  1. LewBr

    LewBr Zombie

    Messages:
    385
    GitHub:
    lewbr
    Hello, i don't know how to get if a player is using for example an Helmet, i do like this:
    PHP:
      if(!$player->getArmorInventory()->getHelmet()){
    to get if a player is using a Helmet or not, how can i do that? for me it doens't works..
     
  2. killer549

    killer549 Spider

    Messages:
    6
    GitHub:
    killer549
    I guess..
    PHP:
     if($player->getArmorInventory()->getHelmet() !== true){
        
    //Do something
    }
    And of course you need to put this in an event or just enable this check by using FOR EXAMPLE command which will enable repeatingtask.. It depends on how you gonna use this.
     
  3. LewBr

    LewBr Zombie

    Messages:
    385
    GitHub:
    lewbr
    Yeah, i am using on PlayerInteract Event, i will test and then i saw if works or not.. Thanks
     
  4. LewBr

    LewBr Zombie

    Messages:
    385
    GitHub:
    lewbr
    doesn't works..
     
  5. Az928

    Az928 Baby Zombie

    Messages:
    140
    GitHub:
    theaz928
    PHP:
    if($player->getArmorInventory()->getHelmet()->isNull() == false){
        
    // Player wearing a helmet
    }
    Also @killer549 you mad bruh? Armor inventory -> getItem/getHelmet doesn't return any bool, it returns Item instance
     
  6. killer549

    killer549 Spider

    Messages:
    6
    GitHub:
    killer549
    Unfortunately I noticed this after replying to this thread. When I attempted to find a way when @LewBr confirmed that this didn't work. "_"
     
  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.