[MySQL]Setcolor
#1

Problem : The color code saves correctly, but it does not set the color.
Objective : Set the color which I saved to the database.


OnPlayerConnect
pawn Код:
format(Query2,sizeof(Query2),"SELECT * FROM `users` WHERE `Name` = '%s'", GetName(playerid));
    mysql_function_query(cHandle, Query2, true, "CheckStats", "d", playerid);

pawn Код:
public CheckStats(playerid, name[])
{
    new rows, fields;
    cache_get_data (rows, fields, cHandle);
    if(rows)
    {
        new mHolder[128], color;
        cache_get_field_content(0, "Color", mHolder, cHandle);
        SetPlayerColor(playerid, color);
    }
    return 1;
}
pawn Код:
// example of colorcode = 0x00CC00FF
format(Query1,sizeof(Query1),"UPDATE `users` SET `Color` = '%s' WHERE `Name` = '%s'", colorcode, GetName(playerid));
    mysql_function_query(cHandle, Query1, false, "", "d", playerid);
Reply
#2

Colours are integers so save it as an integer and load it as an integer.
Reply
#3

I've been trying this
pawn Код:
stock HexToInt(string[]) // By DracoBlue
{
    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;
}
and on saving, I did:

pawn Код:
format(color, sizeof(color), "0x%sFF", mHolder);
        SetPlayerColor(playerid, HexToInt(str));
But my colors are :
0xFFFF00AA
0xFF0000AA
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)