Samp color codes to int.
#1

Hi how to convert samp colors like that:

0xFF0000AA

To int? like 5789642

I saw that thing in zamaroth textdraw editor.
Reply
#2

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

Read that .
Reply
#3

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 );
}
Reply
#4

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
?
Reply
#5

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

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!" );
Reply
#7

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


Forum Jump:


Users browsing this thread: 1 Guest(s)