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

[Solved] Check entity nametag

Discussion in 'Development' started by Kyd, Mar 25, 2017.

  1. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    Hello, I trying to check if entity has nametag c2c or c1c or c3c, but my code is not working. Please help
    PHP:
    /** var Entity $ent */
    $a = array("1""2""3");
    elseif (
    $ent->getNameTag() == "c"print_r(array_values($a)) .  "c"){
             echo 
    "debug";
        }
    }
     
    Last edited: Mar 25, 2017
  2. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    That of course would not work. I believe this is what you were trying to do.
    PHP:
    /** var Entity $ent */
    $a = array("1""2""3");
    foreach (
    $a as $number){
        if (
    $ent->getNameTag() == "c"$number "c"){
             echo 
    "debug";
        }
    }
     
  3. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    Thank you
     
  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.