[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


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)