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

Launcher message

Discussion in 'Development' started by jordi1206, Apr 24, 2017.

  1. jordi1206

    jordi1206 Silverfish

    Messages:
    15
    Hello all,

    How can we set a message like this that will be displayed on the user's launcher?
    Is this possible to do with onPlayerJoin() ?

    [​IMG]
     
  2. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    Wait, I dont understand.. You want onJoin kick player with custom message?
     
  3. jordi1206

    jordi1206 Silverfish

    Messages:
    15
    Yeah something like that, since I'm working on connecting multiple servers together, I cannot use the default ban system. Therefor, everytime an user joins, an API-request will be made. If it returns the user is banned, I need to kick him/her with this message.
     
  4. Jack Noordhuis

    Jack Noordhuis Zombie Pigman Poggit Reviewer

    Messages:
    618
    GitHub:
    JackNoordhuis
    Player::kick(string: $message, book: $isAdmin)
    PHP:
    /** @var $player pocketmine\Player */
    $player->kick(pocketmine\utils\TextFormat::GREEN "Server restarted."false);
     
  5. jordi1206

    jordi1206 Silverfish

    Messages:
    15
    Thanks Jack!

    Any possible options for line breaks?
     
  6. Jack Noordhuis

    Jack Noordhuis Zombie Pigman Poggit Reviewer

    Messages:
    618
    GitHub:
    JackNoordhuis
    \n
     
  7. jordi1206

    jordi1206 Silverfish

    Messages:
    15
    That didn't work
     
  8. Jack Noordhuis

    Jack Noordhuis Zombie Pigman Poggit Reviewer

    Messages:
    618
    GitHub:
    JackNoordhuis
    PHP:
    $string "This a string.\nThis is a new line.";
     
  9. xBeastMode

    xBeastMode Shog Chips

    Messages:
    0
    Make sure to use double quotes for like break (\n) in PHP or if you wish use the PHP_EOL constant instead.
     
  10. Jack Noordhuis

    Jack Noordhuis Zombie Pigman Poggit Reviewer

    Messages:
    618
    GitHub:
    JackNoordhuis
    The PHP_EOL is a PHP (obviously lol) predefined constant that varies per platform (operating system), meaning it will not always be equal to \n (the Linux 'End Of Line' symbol). Reference: http://php.net/manual/en/reserved.constants.php
     
    SOFe and 0x15f like this.
  11. xBeastMode

    xBeastMode Shog Chips

    Messages:
    0
    PHP_EOL is cross platform and it could be used anywhere in command line.
     
  12. Jack Noordhuis

    Jack Noordhuis Zombie Pigman Poggit Reviewer

    Messages:
    618
    GitHub:
    JackNoordhuis
    Where did I say it only works on a specific platform? I merely stated that its value varies across operating systems and it should not be used for sending messages (or any other text) to players.
    Good thing we're not talking about the command line ;)
     
    falk likes this.
  13. xBeastMode

    xBeastMode Shog Chips

    Messages:
    0
    Oops, I didn't get you at first. I believe it's just the same for every Minecraft client and you're right PHP_EOL might not be the same as the Minecraft break line. :D
     
  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.