12.09.2012, 05:55
Hi how to convert samp colors like that:
0xFF0000AA
To int? like 5789642
I saw that thing in zamaroth textdraw editor.
0xFF0000AA
To int? like 5789642
I saw that thing in zamaroth textdraw editor.
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 );
}
0x000000AA
00x000000AA
if( inputtext[ 0 ] < 11 ) return SendCliendMessage( playerid, -1, "ERROR, DUDE!" );
Well.. Every Hex color have 10 characters so you can use:
pawn Код:
|
if( strlen(inputtext) !=10 ) return SendCliendMessage( playerid, -1, "ERROR, DUDE!" );
new col[16] = "FFAABB"; new gcol[16]; format(gcol, sizeof(gcol), "00x%sAA", col);