onJoin setNameTag()

Discussion in 'Development' started by Th3Ang3lo, Jun 13, 2018.

  1. Th3Ang3lo

    Th3Ang3lo Spider Jockey

    Messages:
    32
    GitHub:
    Th3Ang3lo
    Hi, I need help ... How do I set a NameTag on the player using PlayerJoinEvent? Sorry for my bad english. I'm Brazilian.

    code here:

    public function staffJoin(PlayerJoinEvent $event){
    $dono = "Th3Ang3loGam3r";
    $subdono = "SkyderGamer";
    $diretores = ["ZzMarcelozZ", "MrBlendson_7w7"];
    $admins = ["zGuiSS", "StrupeyUs_"];
    $mods = ["DrupperzinPe", "SrEllyBr", "Speed", "zDeleted_7w7"];
    $ajudantes = [null];

    $p = $event->getPlayer();

    if($p->getName() == $dono){
    $player->setDisplayName("§8[§aDono§8]§f {$player->getName()}");
    }
    }
     
  2. Th3Ang3lo

    Th3Ang3lo Spider Jockey

    Messages:
    32
    GitHub:
    Th3Ang3lo
    Error:

    [23:20:25] [Server thread/CRITICAL]: "Could not pass event 'pocketmine\event\player\PlayerJoinEvent' to 'MiniCore v1': Call to a m ember function setDisplayName() on unknown on MiniCore\Main
    [23:20:25] [Server thread/CRITICAL]: Error: "Call to a member function setDisplayName() on unknown" (EXCEPTION) in "/MiniCore/src/ MiniCore/Main" at line 42

    Line 42 is: $player->setDisplayName("§8[§aDono§8]§f {$player->getName()}");
     
  3. Fludixx

    Fludixx Creeper

    Messages:
    4
    GitHub:
    fludixx
    replace $player with $p
    PHP:
    $p->setDisplayName("§8[§aDono§8]§f {$player->getName()}");
     
    Th3Ang3lo likes this.
  4. Th3Ang3lo

    Th3Ang3lo Spider Jockey

    Messages:
    32
    GitHub:
    Th3Ang3lo
    @Fludixx

    It was a lack of attention ... I realized that it was $p and not $player, I solved it myself before replying to this post Thanks for the help anyway.
     
  5. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    Use array
     
  6. RUISMINE

    RUISMINE Silverfish

    Messages:
    17
    GitHub:
    thecgaming
    use permissions instead of Player names, its much easier for bulk players,
     

Share This Page

  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.