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

armor checking

Discussion in 'Development' started by Teamblocket, Mar 12, 2017.

  1. Teamblocket

    Teamblocket Zombie

    Messages:
    301
    GitHub:
    teamblocket
    how can i check if a player has an diamond helmet on them , like wearing it. Thanks :D
     
  2. TheDiamondYT

    TheDiamondYT Zombie

    Messages:
    298
    GitHub:
    TheDiamondYT1
    Last edited: Mar 16, 2017
  3. Teamblocket

    Teamblocket Zombie

    Messages:
    301
    GitHub:
    teamblocket
  4. Teamblocket

    Teamblocket Zombie

    Messages:
    301
    GitHub:
    teamblocket
    What event would i use? am new to this
     
  5. TheDiamondYT

    TheDiamondYT Zombie

    Messages:
    298
    GitHub:
    TheDiamondYT1
    I don't know... When do you need to check if they are wearing a diamond helmet? (Eg when a player gets hit by a player, when a player touches a block etc)
     
  6. Aviv

    Aviv Baby Zombie

    Messages:
    156
  7. TheDiamondYT

    TheDiamondYT Zombie

    Messages:
    298
    GitHub:
    TheDiamondYT1
    Oh whoops
     
  8. DataSyncError

    DataSyncError Silverfish

    Messages:
    20
    GitHub:
    idirtniverse
    What about custom metadata tags?
     
  9. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    PHP:
    $item $player->getInventory()->getHelmet();

    /*
    if($item->getId() === 0){
        //Player doesn't have a helmet on.
    }
    */

    $id $item->getId();
    $meta $item->getDamage();
    $name $item->getName();
    $tags $item->getNamedTag();
     
    DataSyncError likes this.
  10. TheDiamondYT

    TheDiamondYT Zombie

    Messages:
    298
    GitHub:
    TheDiamondYT1
    He wants to check if its a diamond helmet or not, so you need my solution aswell
     
  11. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Code:
    if ($item->getId() === Item:: DIAMOND_HELMET) {
    }
    
     
  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.