PDA

View Full Version : Hex codes in text


MerryDeer
29/11/2016, 02:36 PM
Hi,

How to calculate how much hex codes is in text?

Stinged
29/11/2016, 03:56 PM
{FFFFFF} = 8 characters

Jeffry
29/11/2016, 05:53 PM
{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.

Jefff
29/11/2016, 06:20 PM
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
new str[] = "{ASA}Hello {AAAAAA}there {FFFFFF}wazzap {AA}";
printf("Hex codes in text: %d",ColorsInText(str));

Stinged
30/11/2016, 06:21 PM
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 = 8)