Hex codes in text - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Hex codes in text (
/showthread.php?tid=623232)
Hex codes in text -
MerryDeer - 29.11.2016
Hi,
How to calculate how much hex codes is in text?
Re: Hex codes in text -
Stinged - 29.11.2016
{FFFFFF} = 8 characters
Re: Hex codes in text -
Jeffry - 29.11.2016
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.
Re: Hex codes in text -
Jefff - 29.11.2016
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));
Re: Hex codes in text -
Stinged - 30.11.2016
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 =