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

how to place a text up of player name ?

Discussion in 'Development' started by abdullah, Aug 13, 2017.

  1. abdullah

    abdullah Spider

    Messages:
    14
    GitHub:
    x3boodx
    hello ..

    I want to add text down of player name I use this code :


    <?php

    namespace test;

    use pocketmine\plugin\PluginBase;
    use pocketmine\utils\TextFormat as Color;
    use pocketmine\command\Command;
    use pocketmine\command\commandsender;

    class Main extends PluginBase
    {

    public function onEnable()
    {

    $this->getLogger()->info(Color::GREEN . "Plugin has Enabled");

    }

    public function onDisable()
    {

    $this->getLogger()->info(Color::RED . "Plugin has Disabled");

    }

    public function onCommand(CommandSender $sender, Command $cmd, $lable, array $args)
    {

    switch($cmd->getName())
    {

    case 'test':

    $name = $sender->getName();
    if(isset($args[0]))
    {

    switch($args[0])
    {

    case'ts':
    $sender->setNameTag($name . "
    long text long text long text long text
    long text long text long text long text
    long text long text long text long text
    long text long text long text long text
    long text long text long text long text
    ");

    }
    }
    }
    }
    }

    but the text cover the player skin
    how can I fix it ??
     
    KYUMA likes this.
  2. Irish

    Irish Baby Zombie

    Messages:
    156
    GitHub:
    irishpacks
    Use \n

    PHP:
    $sender->setNameTag($name "
    long text long text long text long text
    long text long text long text long text
    long text long text long text long text
    long text long text long text long text
    long text long text long text long text
    \n\n\n\n\n\n"
    );
    I prefer PHP_EOL which is the constant for \n, but there ya go
     
    jasonwynn10 likes this.
  3. abdullah

    abdullah Spider

    Messages:
    14
    GitHub:
    x3boodx
    does not work
     
  4. Irish

    Irish Baby Zombie

    Messages:
    156
    GitHub:
    irishpacks
    It does work, but you'll have to use a lot of them in order to see the effect.
     
  5. abdullah

    abdullah Spider

    Messages:
    14
    GitHub:
    x3boodx
    I use 102 of them and does not work ☻
     
  6. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    PHP:
    ->setNameTag("\n{YOUR_TEXT}\n{PLAYER_NAME}\n\n");
     
    jasonwynn10 likes this.
  7. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    NO IT IS NO WAY BETTER.
    PHP_EOL becomes \r\n on Windows, which will show up wrongly.
     
  8. Irish

    Irish Baby Zombie

    Messages:
    156
    GitHub:
    irishpacks
    Huh, didn't know that. Thanks for the info!
     
    jasonwynn10 likes this.
  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.