11.06.2012, 13:44
Basically I'm trying to send the players color as a hex value toa database, using a intTohex function to convert the integer value to hex!
Here is the function
And here is the code I'm using to send the value to the database
However I'm not getting the results I wanted... well none at all! Could someone explain how could I achieve this?
Here is the function
Код:
#define IntToDual(%0) IntToBase(%0, 2)
#define IntToOctal(%0) IntToBase(%0, 8)
#define IntToHex(%0) IntToBase(%0, 16)
stock IntToBase(number, const base) {
new str[32];
if(1 < base < 37) {
new
m = 1,
depth = 0;
while (m <= number) {
m *= base;
depth++;
}
for ( ; (--depth) != -1; ) {
str[depth] = (number % base);
number = ((number - str[depth]) / base);
if(str[depth] > 9) str[depth] += 'A'; else str[depth] += '0';
}
}
return str;
}
Код:
new string[128];
format(string, sizeof(string), "INSERT INTO test (Name,Text,Color) VALUES ('%s','%s','%x')", gPlayerName[playerid], text, IntToBase(GetPlayerColor(playerid)));
mysql_query(string);


