Hex codes in text
#1

Hi,

How to calculate how much hex codes is in text?
Reply
#2

{FFFFFF} = 8 characters
Reply
#3

Quote:
Originally Posted by Stinged
Посмотреть сообщение
{FFFFFF} = 8 characters
Actually embedded colors do not support the alpha channel, means it's only 6 characters.

Based on a color in format: 0xRRGGBBAA
You have to pick: {RRGGBB}

Or you use a color picker like this one: http://www.colorpicker.com/
Simply pick the Code in the box and put it between braces.
Reply
#4

pawn Код:
ishex(c)
    return (('0' <= c <= '9') || ('A' <= toupper(c) <= 'F'));

ColorsInText(const str[])
{
    new num, colors;
    for(new i = 0, c, d; (c = str[i]) != EOS; i++)
    {
        if(c == '{')
        {
            num = 0;
            for(d = i + 1; d < i + 7; d++)
            {
                if(!str[d]) break;
                if(!ishex(str[d])) break;

                num++;
            }
            if(num == 6 && str[d] == '}') colors++;
        }
    }
    return colors;
}
Usage
pawn Код:
new str[] = "{ASA}Hello {AAAAAA}there {FFFFFF}wazzap {AA}";
printf("Hex codes in text: %d",ColorsInText(str));
Reply
#5

Quote:
Originally Posted by Jeffry
Посмотреть сообщение
Actually embedded colors do not support the alpha channel, means it's only 6 characters.

Based on a color in format: 0xRRGGBBAA
You have to pick: {RRGGBB}

Or you use a color picker like this one: http://www.colorpicker.com/
Simply pick the Code in the box and put it between braces.
Sorry for the late response (I didn't see the topic until now), but what the poster is talking about is embedded colors.
Код:
{0000FF}blue {FF0000}red
blue red
And he's asking if they count as characters (Since SendClientMessage is limited to 144 characters).

Also, you can clearly see I didn't add any the alpha channel, but { } also count as 2 chars. (6 + 2 =
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)