SA-MP Forums Archive
Problem with HexToInt - 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: Problem with HexToInt (/showthread.php?tid=661382)



Problem with HexToInt - Kraeror - 02.12.2018

Hello guys, I'm using the function HexToInt, but I have a problem.
When I try to set the player's color to red it sets it as blue.
Here is my code:
PHP код:
format(TheColorsizeof(TheColor), "0xFF0000FF");
SetPlayerColor(playeridHexToInt(TheColor)); 
And here is my HexToInt function:
PHP код:
stock HexToIntstring[ ] )
{
    if( 
string] == ) return ( );
    new 
i;
    new 
cur 1;
    new 
res 0;
    for( 
strlen( string ); 0-- )
    {
        if( 
string] < 58 )
        {
            
res res cur * ( string] - 48 );
        }
        else
        {
            
res res cur * ( string] - 65 10 );
            
cur cur 16;
        }
    }
    return ( 
res );




Re: Problem with HexToInt - ItsRobinson - 02.12.2018

0000FF is the hex for blue
FF0000 is the hex for red.


Re: Problem with HexToInt - Kraeror - 02.12.2018

I know that bro, but the output is blue. Why The 0xFF0000FF is for red, but in the output it's blue, I think there is a problem with the HexToInt


Re: Problem with HexToInt - Kraeror - 02.12.2018

I retyped it and it got fixed. Thanks for trying to help me!


Re: Problem with HexToInt - ItsRobinson - 02.12.2018

0xFF0000FF = blue
0xFFFF0000 = red

0xFFRRGGBB

0xFF = Opacity (FF = 100%, 00 = 0%)
RR = Red
GG = Green
BB = Blue

Just search for a hex generator, find one and then whatever color you want, just put 0xFF before it, i.e.

Green hex would be: 0xFF00FF00


Re: Problem with HexToInt - Dayrion - 02.12.2018

Or you can just use sscanf ehh.. Waaay simpler than a custom function.