Hex codes in text
#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


Messages In This Thread
Hex codes in text - by MerryDeer - 29.11.2016, 14:36
Re: Hex codes in text - by Stinged - 29.11.2016, 15:56
Re: Hex codes in text - by Jeffry - 29.11.2016, 17:53
Re: Hex codes in text - by Jefff - 29.11.2016, 18:20
Re: Hex codes in text - by Stinged - 30.11.2016, 18:21

Forum Jump:


Users browsing this thread: 1 Guest(s)