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

Solved SetNameTag

Comments in 'Plugin Development' started by FlamingGenius, Oct 2, 2015.

Thread Status:
Not open for further replies.
  1. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    Where is the setNameTag function? Ive looked in all the places i imagine it would be an i cant seem to find it or maybe its not a piblic function?
  2. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    Player.php
  3. TheMaks
    Offline

    TheMaks Active Member

    Joined:
    Jul 19, 2015
    Posts:
    58
    Minecraft User:
    TheMaks
    PHP:
    <?
    public function 
    onJoin(PlayerJoinEvent $e)
    {
       
    $p $e->getPlayer();
          if(
    $p instanceof Player)
          {
             
    $name $p->getName();
             
    $p->setNameTag($name."\nTag!!!");
          }
    Andrey Nazarchuk likes this.
  4. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    FlamingGenius likes this.
  5. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    Did i ask for this? No i dont believe i did please read the question next time
  6. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
  7. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    Well yea i get that im just saying maybe add it to Player.php because its a lot simpler to put
    PHP:
    use pocketmine\Player;
    Instead of
    PHP:
    use pocketmine\entity\Entity;
  8. Andrey Nazarchuk
    Offline

    Andrey Nazarchuk Active Member

    Joined:
    Dec 30, 2013
    Posts:
    332
    Minecraft User:
    digita1eclipse
    Wow you guys are 45540135, what @TheMaks Said is very useful, please don't act like @Gamecrafter , one is enough.
  9. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    It's called inheritance. It's an OOP thing. A Player extends a Human, and a Human extends a Creature, and a Creature extends Living, and finally Living extends Entity.
  10. Andrey Nazarchuk
    Offline

    Andrey Nazarchuk Active Member

    Joined:
    Dec 30, 2013
    Posts:
    332
    Minecraft User:
    digita1eclipse
    I came to this thread looking for how to set a name tag, i'm sure many more people will come here for the same thing.
  11. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    Its actually not useful
    You see he provided no explanation for his code and if i had no knowledge of PHP and the pocketmine API i would have no idea what it meant

    Second of all it did not answer my question

    Third its gets on my nerves bc certain people *cough* think i am copying peoples code when im not just because a few things are similar so if people could refrain from posting codes without explanation that would be great
    PEMapModder likes this.
  12. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    He's not directly asking how to set a nametag, he's asking where the function is, because he couldn't find it where every newb would look: \pocketmine\Player, so I pointed him to \pocketmine\entity\Entity, which was the answer. So if you excuse me, rub your eyes, and read the very first post in this thread.
    FlamingGenius likes this.
  13. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    Fyi
    PHP:
    <?php
    namespace FlamingGenius\ColorTag;

    use 
    pocketmine\utils\Config;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\Player;
    use 
    pocketmine\entity\Entity;

    class 
    ColorTag extends PluginBase{
     
    $player $this->getServer()->getPlayer();

     public function 
    onCommand(CommandSender $senderCommand $command$label, array $args){
     
    $cmd $this->command->getName();
     
    $tag $args
     
    if($tag == "Admin""Moderator" "Owner"){
      if(
    strtolower($cmd) == "st"){
       
    $setTag $this->getConfig()->get($tag);
       
    $player->setNameTag($setTag);
      }
     }
      else{
       
    $sender->sendMessage("┬žbTag not reconized");
      }
     }



    }


    ?>
    I think my code beats his :D
  14. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    Yea i know i was in the middle of coding when everyone started posting on here but yea i know where the error is
  15. Andrey Nazarchuk
    Offline

    Andrey Nazarchuk Active Member

    Joined:
    Dec 30, 2013
    Posts:
    332
    Minecraft User:
    digita1eclipse
    I did, but I found @TheMaks post useful, and you both yelled at him for posting something useful.
    Now you're just confusing yourself and me...
    "he provided no explanation for his code and if i had no knowledge of PHP and the pocketmine API i would have no idea what it meant" If you dont know enough php to understand his post then why are you writing plugins?

    "Second of all it did not answer my question" It answered mine and many other peoples.

    "certain people *cough* think i am copying peoples code when im not just because a few things are similar so if people could refrain from posting codes without explanation that would be great" No one said you were copying in this post.
  16. Andrey Nazarchuk
    Offline

    Andrey Nazarchuk Active Member

    Joined:
    Dec 30, 2013
    Posts:
    332
    Minecraft User:
    digita1eclipse
    The player would have to run that command every time they joined to get a custom tag, so no, its less useful.
  17. Andrey Nazarchuk
    Offline

    Andrey Nazarchuk Active Member

    Joined:
    Dec 30, 2013
    Posts:
    332
    Minecraft User:
    digita1eclipse
    You guys attacked TheMaks and he posted something that would be useful to 99% of the people wondering how to set name tags, which is what I came here for.

    EDIT: because the Title said "SetNameTag", not "What is the include line for setNameTag?"
  18. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Mind that he didn't ask how to set nametags, but he was asking in which class setNameTag() was located. And we did not "attack", we told him to stay out of it, because he wasn't helping/answering @FlamingGenius's question. Please read the first post next time before accusing me for "attacking" someone. Simply posting code will not help, you need to explain it.
  19. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    Different question: How do you know how setNameTag works (only asking so it can assist me and other new learners of Pocketmine API)
  20. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    Different question: How do you know how setNameTag works (only asking so it can assist me and other new learners of Pocketmine API)
Thread Status:
Not open for further replies.

Share This Page

Advertisement