[Include] SendLongMessage (Accepts '\n', emb. colors and prefixes!)
#1

SendLongMessage

Hey! This my first release on SA:MP forums, but I have been scripting from a long time ago, though. This include not only 'trims' the text to the max length you want, but also accepts line-breaks (\n), sends prefixes of each message and is completely compatible with 0.3c embedded colors.

Main functions:
pawn Код:
SendLongMessage(playerid, color, message[], charlimit = 80, prefix[] = "")
SendLongMessageToAll(color, message[], charlimit = 80, prefix[] = "")
Internally used functions:
pawn Код:
GetLastEmbColor(string[])
IsValidEmbColor(string[])
IsValidHexChar(c)

Output Example

SendLongMessage(playerid, 0xFF00AA, "I am so\n {FFDDDD}awesome{FFFFFF}.\n And {000000}no one{FFFFFF} can\n deny. ", 20, "Dear: ")
[20:45:07] Dear: {FF00AA}I am so
[20:45:07] Dear: {FF00AA} {FFDDDD}awes
[20:45:07] Dear: {FFDDDD}ome{FFFFFF}.
[20:45:07] Dear: {FFFFFF} And {000000}
[20:45:07] Dear: {000000}no one{FFFFFF}
[20:45:07] Dear: {FFFFFF} can
[20:45:07] Dear: {FFFFFF} deny.
Example of Use
pawn Код:
public OnPlayerText(playerid, text[])
{
    static
        ChatLimit[MAX_PLAYERS];

    if(strcmp("!chatlen", text, false) == 0)
    {
        if(text[10] == 0)
        {
            return SendClientMessage(playerid, -1, "!chatlen [75 - 128]");
        }
        new tmp[5], value;
        strmid(tmp, text, 11, strlen(text));

        ChatLimit[playerid] = strval(tmp);
        return 1;
    }
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);

    SendLongMessageToAll(0xFF00AA, text, ChatLimit[playerid], pName);
    return 0;
}


Important Notes
  1. IMPORTANT: Colors muse be defined WITHOUT ALPHA.
    That means you should define your colors as
    #define COLOR_WHITE 0xFFFFFF
  2. Otherwise, when you 'color' variable WON'T work. (SA:MP bug).
  3. Prefixes COUNT as the output.
    That means: string = charlen + prefix + 8 (color).
  4. Prefixes have White as default color.
    To change it, you must use embeded colors.

Pastebin:
http://pastebin.com/a0VUfLHT

Thanks to:
Amit_B: Helping me to figure some stuff out.
Slice: OH GOD. THE PAWN PLAYGROUND THINGY IS JUST AWESOME. DUDE.

Have fun! And keep the credits. Seriously, I spent the entire afternoon doing this.
Reply
#2

Hmm nice but that 0.3c Colors are already added by SA-MP team..
Reply
#3

Quote:
Originally Posted by SpiderWalk
Посмотреть сообщение
Hmm nice but that 0.3c Colors are already added by SA-MP team..
I know. What I meant was that If I had done the script without support to 0.3c colors, for example, when you set the color to {BBAABB}, when the string is jumped to another line, the color would be white or whatever. Like:
Код:
{FFFFFF}Testhell{FF00AA}asas\n
{FF00AA}anotherline
And if the color tag is in the middle of the line break, the scripts breaks the line before the color tag, so the message won't be buggy at all.
Reply
#4

nice,do you know what Slice's script even do?
Reply
#5

Quote:
Originally Posted by xkirill
Посмотреть сообщение
nice,do you know what Slice's script even do?
Actually, that's a browser-compiler. If you put your code in the box and click run, you'll have a server. Sadly you are limited to printf() though.
Reply
#6

Thats nice
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)