Checking if a player has entered a hex
#1

See the topic title - How would I go about doing this? A hex code in this system would be entered like so "{FFFFFF}", which is the hexadecimal code for white, but, how would I detect it? Just finding "{ }" wouldn't be accurate enough.
Reply
#2

My old version

pawn Код:
stock bool:IsHex(string[])
{
    new pos[2] = {-1,-1},cnt,cur;
    while((pos[0] = strfind(string, "{", true, (pos[0] + 1))) != -1)
    {
        cnt = 0;
        for(new d = (pos[0]+1); d < (pos[0]+7); d++)
        {
            cur = string[d];
            if(cur != '\0')
                if(('0' <= cur <= '9') || ('A' <= cur <= 'F') || ('a' <= cur <= 'f'))
                {
                    pos[1] = d;
                    cnt++;
                }
        }
        if((cnt == 6) && (string[pos[1]+1] == '}'))
            return true;
    }
    return false;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)