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

Player TagName with Color

Comments in 'Plugin Development' started by LoveToBeDev, Aug 31, 2015.

  1. LoveToBeDev
    Offline

    LoveToBeDev Active Member

    Joined:
    Aug 19, 2015
    Posts:
    55
    Minecraft User:
    LoveToBeDev
    Hello Guys, i wanted to use some experimental options, and as the title said, im trying to change the player tag color when they execute the command, but... i investigated already and it does not gives me any results!! help please!!
  2. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    $player->setNameTag("§colorcode blah blah blah");
  3. Exxarion
    Offline

    Exxarion Active Member Plugin Developer

    Joined:
    Jan 5, 2014
    Posts:
    242
    Plugins:
    1
    Minecraft User:
    Notch
    PHP:
    $player //Declare player, yada yada yada;
    $player->setNameTag("§a$player"); //§a is green, change it to something else if you would like.
  4. LoveToBeDev
    Offline

    LoveToBeDev Active Member

    Joined:
    Aug 19, 2015
    Posts:
    55
    Minecraft User:
    LoveToBeDev
    Cant be like:


    PHP:
    $sender->setNameTag("§c$name");     ?
  5. LoveToBeDev
    Offline

    LoveToBeDev Active Member

    Joined:
    Aug 19, 2015
    Posts:
    55
    Minecraft User:
    LoveToBeDev
    oh, man, it says that i don't have a variable called "$player" help!
  6. Exxarion
    Offline

    Exxarion Active Member Plugin Developer

    Joined:
    Jan 5, 2014
    Posts:
    242
    Plugins:
    1
    Minecraft User:
    Notch
    $sender represents the command sender, and you can change $player to $name.
  7. LoveToBeDev
    Offline

    LoveToBeDev Active Member

    Joined:
    Aug 19, 2015
    Posts:
    55
    Minecraft User:
    LoveToBeDev
    but, what do i need to establish on $player??
  8. LoveToBeDev
    Offline

    LoveToBeDev Active Member

    Joined:
    Aug 19, 2015
    Posts:
    55
    Minecraft User:
    LoveToBeDev
    bro? because its asking me to define player :(
  9. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    If you want $player as the name,
    PHP:
    $player $sender->getName();
  10. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Learn PHP. You are just blindly copying code that people give you, without knowing how it works.
  11. LoveToBeDev
    Offline

    LoveToBeDev Active Member

    Joined:
    Aug 19, 2015
    Posts:
    55
    Minecraft User:
    LoveToBeDev
    Actually, yeah, i make my code, this is not just PHP, this is Pocketmine API, learn definitions men, good luck :D
  12. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    You make your own codes? XD
    hoyinm14mc likes this.
  13. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    If you really know PHP, you should know that a variable cannot be defined from nothingness. You didn't define $player. You can't blame it on the API, because superglobals only exist in PHP for the default ones ($_REQUEST, $_GET, $_POST, $GLOBALS, $_SESSION, $_FILES).
    Please learn PHP and learn the basics about variables.
    hoyinm14mc likes this.
  14. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    But he said he knew how to make codes... XD
  15. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    PHP:
    public function onCommand(CommandSender $senderCommand $command$label, array $args){
    if(
    strtolower($command->getName()) === 'nametag'){
    if(isset(
    $args[0])){
    switch(
    strtolower($args[0])){
    case 
    "blue"
    case "bl":
    $sender->setNameTag(TextFormat::BLUE.$sender->getDisplayName());
    $sender->sendMessage('Your name tag is now blue');
    }
    }
    }
    }
  16. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Why not use getNameTag instead? And TextFormat::clean() if you want.
  17. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    I'll keep that in mind.

Share This Page

Advertisement