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

SendMessage

Comments in 'Plugin Development' started by IcePL, Feb 16, 2016.

  1. IcePL
    Offline

    IcePL New Member

    Joined:
    Feb 16, 2016
    Posts:
    73
    Minecraft User:
    IcePL
    How to replace this code:
    PHP:
                $this->getServer()->broadcastMessage
    To SendMessage to a player?
  2. Vaivez66
    Offline

    Vaivez66 Notable Member Plugin Developer

    Joined:
    Jun 10, 2015
    Posts:
    402
    Plugins:
    2
    I don't understand what do you mean. You want to broadcast message, or send message to specific player?
    KubixQ likes this.
  3. IcePL
    Offline

    IcePL New Member

    Joined:
    Feb 16, 2016
    Posts:
    73
    Minecraft User:
    IcePL
    Send message to player.I must edit tierloot file to send message to player.Sorry for my bad englisch.
  4. Vaivez66
    Offline

    Vaivez66 Notable Member Plugin Developer

    Joined:
    Jun 10, 2015
    Posts:
    402
    Plugins:
    2
    Basic:
    PHP:
    $player->sendMessage('message');
    But in this case, you have to understand the source code of TierLoot. Otherwise, that code will not work.
  5. IcePL
    Offline

    IcePL New Member

    Joined:
    Feb 16, 2016
    Posts:
    73
    Minecraft User:
    IcePL
    Ok this is ok thanks for help.
  6. PolskiTHEPLAYER
    Offline

    PolskiTHEPLAYER New Member

    Joined:
    Apr 1, 2015
    Posts:
    55
    Minecraft User:
    Flsmers
    And
    $this->sendMessage("Message");
  7. KubixQ
    Offline

    KubixQ Active Member

    Joined:
    Sep 13, 2015
    Posts:
    85
    Minecraft User:
    KubixQ
    Nope. -,-
    applqpak, Marttinek and PocketKiller like this.
  8. PolskiTHEPLAYER
    Offline

    PolskiTHEPLAYER New Member

    Joined:
    Apr 1, 2015
    Posts:
    55
    Minecraft User:
    Flsmers
    $this->sendMessage("§a • Wydropiłeś z stone'a - Redstone • ");
    Yes ;)
  9. KubixQ
    Offline

    KubixQ Active Member

    Joined:
    Sep 13, 2015
    Posts:
    85
    Minecraft User:
    KubixQ
    @Vaivez66 give our a good code, so why you spamming?
    applqpak, Marttinek and PocketKiller like this.
  10. PolskiTHEPLAYER
    Offline

    PolskiTHEPLAYER New Member

    Joined:
    Apr 1, 2015
    Posts:
    55
    Minecraft User:
    Flsmers
    I don't wirte to you ;)
  11. KubixQ
    Offline

    KubixQ Active Member

    Joined:
    Sep 13, 2015
    Posts:
    85
    Minecraft User:
    KubixQ
    Stop this spam, you can talk in private message, not there..
    applqpak, Marttinek and PocketKiller like this.
  12. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    $player->sendMessage('message'); I don't like the use of ''. Use "" instead
    and BTW using § for ccolours is not good idea use TextFormat::Colour!
    PocketKiller, PEMapModder and KubixQ like this.
  13. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Stop spamming incorrect code. If you dont know how to code well, dont try to help. Simple.
  14. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    It doesnt really matter what method you use. Most people dont have '§' so they choose to use TextFormat.
    Or maybe they just think TextFormat looks better.
    applqpak likes this.
  15. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    • About "": It is common to use "" unless you want to use literal $ in your string, or if you don't want to escape the backslash with double backslash. This may sound like bad practice, but it is actually very common in cases like regular expression.
    • About TextFormat: it does matter. Two reasons:
      1. MCPE may deprecate the use of the section sign in the future. Using the section sign may make your plugin incompatible in future MCPE versions. @shoghicp has confirmed that there is work about that.
      2. Although you would make sure your code is written in UTF-8 anyway, we usually avoid using Unicode characters in string literals in programming code if it can be prevented. Even @shoghicp paid extra attention to this issue when defining TextFormat::ESCAPE, because who knows if some day something wrong happened and your text editor accidentally saved your code as ANSI? To prevent these accidents, why not just use the TextFormat constants?
    Talking of encoding, (off-topic) also be aware that Windows uses CRLF by default. If you are sending players multiple messages by separating lines, but you code it like this:
    PHP:
    $player->sendMessage("This is line 1.
    This is line 2.
    This is line 3."
    );
    Or using HEREDOC/NOWDOC (I know the differences between them, but I never learnt to know which name is which without looking at PHP documentation every time ;P):
    PHP:
    $player->sendMessage(<<<END_OF_MESSAGE
    This is line 1.
    This is line 2.
    This is line 3.
    END_OF_MESSAGE
    );
    You have to be careful. There might be unexpected line endings. If you are doing this, you may want to use str_replace("\r", "", $message) or str_replace("\r\n", "\n", $message) to fix it.
    Hotshot_9930, KubixQ and PocketKiller like this.
  16. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    ERROR: Undefined function sendMessage().
  17. IcePL
    Offline

    IcePL New Member

    Joined:
    Feb 16, 2016
    Posts:
    73
    Minecraft User:
    IcePL
    It's already learned a little about php api pm and already know thanks to all for help me.

Share This Page

Advertisement