Problem with HexToInt
#1

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

Reply
#2

0000FF is the hex for blue
FF0000 is the hex for red.
Reply
#3

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
Reply
#4

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

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
Reply
#6

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


Forum Jump:


Users browsing this thread: 1 Guest(s)