SA-MP Forums Archive
Samp color codes to int. - 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: Samp color codes to int. (/showthread.php?tid=376899)



Samp color codes to int. - budelis - 12.09.2012

Hi how to convert samp colors like that:

0xFF0000AA

To int? like 5789642

I saw that thing in zamaroth textdraw editor.


Re: Samp color codes to int. - [HiC]TheKiller - 12.09.2012

https://sampforum.blast.hk/showthread.php?tid=200876

Read that .


Re: Samp color codes to int. - Roach_ - 12.09.2012

Maybe this little function will help you:
pawn Код:
stock HexToInt( string[ ] )
{
    if( string[ 0 ] == 0 ) return ( 0 );

    new i;
    new cur = 1;
    new res = 0;
    for( i = strlen( string ); i > 0; i -- )
    {
        if( string[ i - 1 ] < 58 )
        {
            res = res + cur * ( string[ i - 1 ] - 48 );
        }
        else
        {
            res = res + cur * ( string[ i - 1 ] - 65 + 10 );
            cur = cur * 16;
        }
    }
   
    return ( res );
}



Re: Samp color codes to int. - budelis - 12.09.2012

Thx a lot. Next thing. I want to do player can change color his self. I give him dialog, and he have to input SAMP COLOR CODE IN like:

Код:
0x000000AA
How to make player must write this format if he write like that:

Код:
00x000000AA
?


Re: Samp color codes to int. - Roach_ - 12.09.2012

Well.. Every Hex color have 10 characters so you can use:
pawn Код:
if( inputtext[ 0 ] < 11 ) return SendCliendMessage( playerid, -1, "ERROR, DUDE!" );



Re: Samp color codes to int. - [MM]RoXoR[FS] - 12.09.2012

Quote:
Originally Posted by Roach_
Посмотреть сообщение
Well.. Every Hex color have 10 characters so you can use:
pawn Код:
if( inputtext[ 0 ] < 11 ) return SendCliendMessage( playerid, -1, "ERROR, DUDE!" );
No, it wont work.

pawn Код:
if( strlen(inputtext) !=10  ) return SendCliendMessage( playerid, -1, "ERROR, DUDE!" );



Re: Samp color codes to int. - Audiophr3ak - 12.09.2012

Is there any way to store FFAABB as a string or something in enum/array an then use it in GangZoneShowForPlayer (transform it to 00xFFAABBAA) without defining? I want to use RGB (FFAABB) in both systems: chat and gang zones.

Something like this:
pawn Код:
new col[16] = "FFAABB"; new gcol[16]; format(gcol, sizeof(gcol), "00x%sAA", col);