Chat HEX colors
#1

Hey.

I wanna know how to enable hex colors in chat.

So basically I want to write in chat: {FF0000} Hello world.

To get: Hello world.



I really hope you can help me.
Reply
#2

this was made by Y-Less.

put this above OnPlayerText
pawn Код:
ReColor(text[])
{
    new
        pos = -1;
    while ((pos = strfind(text, "(", false, pos + 1)) != -1)
    {
        new
            c = pos + 1,
            n = 0,
            ch;
        // Note that the order of these is important!
        while ((ch = text[c]) && n != 6)
        {
            if (!('a' <= ch <= 'f' || 'A' <= ch <= 'F' || '0' <= ch <= '9'))
            {
                break;
            }
            ++c;
            ++n;
        }
        if (n == 6 && ch == ')')
        {
            text[pos] = '{';
            text[c] = '}';
        }
    }
}
and this at the begenning of OnPlayerText:
pawn Код:
ReColor(text);
although now, you use (FF0000) instead of {FF0000}
Reply
#3

Hmm, I didn't quite understand this.

Can you explain it to me a little? Where should I put this ReColor(text); ?
Reply
#4

if you have the callback "OnPlayerText(playerid,text[])" then in there. otherwise, add
pawn Код:
public OnPlayerText(playerid, text[])
{
    ReColor(text);
    return 1;
}
you can put the function anywhere in the script, but its easiest to find above OnPlayerText
Reply
#5

Now it's working, thanks a lot.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)