Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Get nametag players in foreach

Comments in 'Plugin Development' started by KaitoDoDo, Mar 26, 2016.

  1. KaitoDoDo
    Offline

    KaitoDoDo New Member

    Joined:
    Feb 10, 2016
    Posts:
    17
    Minecraft User:
    KaitoDoDoYT
    I need the specific nameTag of the players in foreach for ask if someone contains a word
  2. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Whuuut? :eek:
    applqpak likes this.
  3. applqpak
    Offline

    applqpak Active Member Plugin Developer

    Joined:
    Dec 16, 2015
    Posts:
    284
    Plugins:
    1
    Minecraft User:
    applqpak
    I don't fully understand what you're saying, but from what I understand you want to grab all name tags of players?

    PHP:
    foreach($this->getServer()->getOnlinePlayers as $value)
    {

        
    $nametag $value->getNameTag();

    }
    Last edited: Mar 27, 2016
    Primus likes this.
  4. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    There is no need for $key.
    applqpak likes this.
  5. KaitoDoDo
    Offline

    KaitoDoDo New Member

    Joined:
    Feb 10, 2016
    Posts:
    17
    Minecraft User:
    KaitoDoDoYT
    thanks, i try this
  6. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,130
    Plugins:
    4
    Minecraft User:
    iksaku
    To simplify the code:
    PHP:
    foreach($this->getServer()->getOnlinePlayers() as $p){
        
    /* some of your code: */ $p->getNameTag();
    }
    KaitoDoDo, applqpak and Primus like this.
  7. applqpak
    Offline

    applqpak Active Member Plugin Developer

    Joined:
    Dec 16, 2015
    Posts:
    284
    Plugins:
    1
    Minecraft User:
    applqpak
    Edited :p

Share This Page

Advertisement