SA-MP Forums Archive
Checking if a player has entered a hex - 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: Checking if a player has entered a hex (/showthread.php?tid=322141)



Checking if a player has entered a hex - 2KY - 29.02.2012

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.


Re: Checking if a player has entered a hex - Jefff - 29.02.2012

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;
}