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

display name specific to player

Discussion in 'Development' started by Zuruki, Apr 19, 2017.

  1. Zuruki

    Zuruki Baby Zombie

    Messages:
    118
    GitHub:
    zuruki
    For example.. there is two teams.
    the members of each teams see their teammates display name in green, and enemies in red. this happens for both teams.
    a spectator sees all in grey.
    how is this possible?
     
  2. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
  3. Zuruki

    Zuruki Baby Zombie

    Messages:
    118
    GitHub:
    zuruki
    oakay thankyou
     
  4. TheDiamondYT

    TheDiamondYT Zombie

    Messages:
    298
    GitHub:
    TheDiamondYT1
    Zuruki likes this.
  5. Zuruki

    Zuruki Baby Zombie

    Messages:
    118
    GitHub:
    zuruki
    I really don't understand man :(
     
  6. TheDiamondYT

    TheDiamondYT Zombie

    Messages:
    298
    GitHub:
    TheDiamondYT1
    Since you havent bothered to show any of your current code, dont ask me if you cant get this to work. Its just an idea.

    PHP:
    use pocketmine\Player;
    use 
    pocketmine\utils\TextFormat;

    public function 
    getColor(Player $himPlayer $me): string {  
        
    $hisTeam $this->getPlayerInTeam($him);
        
    $myTeam $this->getPlayerInTeam($me); // idk what the code is to get the team
     
        
    if($hisFaction === $myTeam) {
            return 
    TextFormat::GREEN;
        }
        elseif(
    $hisTeam === /* team */) {
            return 
    TextFormat::RED;
        }
        elseif(
    $hisTeam === /* team */) {
            return 
    TextFormat::YELLOW;
        } else {
            return 
    TextFormat::WHITE// Not in a team
        
    }
    }
     
    Zuruki and Primus like this.
  7. Primus

    Primus Zombie Pigman

    Messages:
    749
    Zuruki likes this.
  8. Zuruki

    Zuruki Baby Zombie

    Messages:
    118
    GitHub:
    zuruki
    thank you friends!
     
  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.