SA-MP Forums Archive
Player color is a string or integer? - 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: Player color is a string or integer? (/showthread.php?tid=433871)



Player color is a string or integer? - newbienoob - 30.04.2013

title


Re: Player color is a string or integer? - Lordzy - 30.04.2013

It's hex, I guess. Not a string anyway.


Re: Player color is a string or integer? - Pottus - 30.04.2013

A HEX is actually a integer but if your supplying a HEX value as input it will be a string, you can use sscanf.

pawn Код:
new int;
sscanf(params, "h", color);
This stock will check if the value you entered is a valid HEX value remember that it only accepts HEX values in a 0x00000000 format it's designed specifically for colors only.

pawn Код:
// Is string a hexvalue
stock IsHexValue(hstring[])
{
    if(strlen(hstring) < 10) return 0;
    if(hstring[0] == 48 && hstring[1] == 120)
    {
        for(new i = 2; i < 10; i++)
        {
            if(hstring[i] == 48 || hstring[i] == 49 || hstring[i] == 50 || hstring[i] == 51 || hstring[i] == 52 ||
                hstring[i] == 53 || hstring[i] == 54 || hstring[i] == 55 || hstring[i] == 56 || hstring[i] == 57 ||
                hstring[i] == 65 || hstring[i] == 66 || hstring[i] == 67 || hstring[i] == 68 || hstring[i] == 69 ||
                hstring[i] == 70) continue;
            else return 0;
        }
    }
    else return 0;
    return 1;
}