SA-MP Forums Archive
IntToHex ... errors. - 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: IntToHex ... errors. (/showthread.php?tid=373350)



IntToHex ... errors. - Edvin - 30.08.2012

Hi guys

Finally I found the "IntToHex" function, and when I use it to convert colors like: 0xFFFFFFFF into HEX colors, like 'FFFFFF' it gave me errors:
Код:
D:\RAS\Build 26\gamemodes\RAS.pwn(11477) : error 035: argument type mismatch (argument 1)
D:\RAS\Build 26\gamemodes\RAS.pwn(11477) : error 006: must be assigned to an array
D:\RAS\Build 26\gamemodes\RAS.pwn(13648) : error 006: must be assigned to an array
Lines:
Код:
11477: mysql_get_field( "ChatColor", Field );      PlayerInfo[ extraid ][ p_TextColor ] = IntToHex( Field );
13648: PlayerInfo[ playerid ][ p_TextColor ]           = IntToHex( 0xFFFFFFFF );
And here is the "IntToHex" function:
pawn Код:
stock IntToHex( number )
{
    new
        m = 1,
        depth = 0
    ;

    while ( number >= m )
    {
        m = m*16;
        depth++;
    }
    depth--;
   
    new
        str[ 125 ]
    ;
    for ( new i = depth; i >= 0; i-- )
    {
        str[i] = ( number & 0x0F) + 0x30; // + (tmp > 9 ? 0x07 : 0x00)
        str[i] += (str[i] > '9') ? 0x07 : 0x00;
        number >>= 4;
    }
    str[ 8 ] = '\0';
    return str;
}
What is the problem?


Re: IntToHex ... errors. - Misiur - 30.08.2012

Variable field is a string, IntToHex requires tagless variable.

pawn Код:
PlayerInfo[ extraid ][ p_TextColor ] = IntToHex( Field );
//Changes to
PlayerInfo[ extraid ][ p_TextColor ] = IntToHex( strval(Field) );
Could you show your PlayerInfo enum on field p_TextColor


Re: IntToHex ... errors. - Edvin - 30.08.2012

Quote:
Originally Posted by Misiur
Посмотреть сообщение
Variable field is a string, IntToHex requires tagless variable.

pawn Код:
PlayerInfo[ extraid ][ p_TextColor ] = IntToHex( Field );
//Changes to
PlayerInfo[ extraid ][ p_TextColor ] = IntToHex( strval(Field) );
Could you show your PlayerInfo enum on field p_TextColor
Ok, now don't show this error:
Код:
D:\RAS\Build 26\gamemodes\RAS.pwn(11477) : error 035: argument type mismatch (argument 1)
But these errors still showing:
Код:
D:\RAS\Build 26\gamemodes\RAS.pwn(11477) : error 006: must be assigned to an array
D:\RAS\Build 26\gamemodes\RAS.pwn(13648) : error 006: must be assigned to an array
---
pawn Код:
enum p_Info
{
    ...
    p_TextColor,
};
Here is the p_TextColor var.

--------------------------
Solved