PDA

View Full Version : Mysql Load/Save Colors


Richie©
24/01/2013, 07:24 PM
How to save and load colors like this in mysql db?


#define COLOR_RED 0xAA3333AA


Im making system so i can dynamicly change a team color in game and it saves in TeamInfo in the DB, and ofc loads correctly like the other data.


Loading it from DB:
cache_get_field_content(i, "Colour", Data), TeamInfo[teamid][tColour] = Data;

Saving it to DB:
`Colour` = %x", TeamInfo[teamid][tColour] );
How to do it correct?

And is the Colour field in DB supposed to be varchar?

Vince
24/01/2013, 07:45 PM
Treat it like any other normal integer value. The hexadecimal number system is just a way of representation.

Richie©
24/01/2013, 08:45 PM
So when setting the colour i can do this?
TeamInfo[i][tColour] = strval(inputtext);

Vince
24/01/2013, 09:53 PM
If you're converting from user input then you're probably better off using sscanf.

Richie©
24/01/2013, 10:26 PM
Ok, it worked out fine now. Thanks Vince!

AiRaLoKa
17/05/2014, 05:10 AM
should i do this when setting my player's color(not on the /color command but on OnPlayerConnect) ??

new color;
color = pInfo[playerid][pColor];
color <<= 8;
color |= 0xFF;
SetPlayerColor(playerid, color);