Mysql Load/Save Colors
#1

How to save and load colors like this in mysql db?

pawn Код:
#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:
pawn Код:
cache_get_field_content(i, "Colour", Data),    TeamInfo[teamid][tColour] = Data;
Saving it to DB:
pawn Код:
`Colour` = %x", TeamInfo[teamid][tColour] );
How to do it correct?

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

Treat it like any other normal integer value. The hexadecimal number system is just a way of representation.
Reply
#3

So when setting the colour i can do this?
pawn Код:
TeamInfo[i][tColour] = strval(inputtext);
Reply
#4

If you're converting from user input then you're probably better off using sscanf.
Reply
#5

Ok, it worked out fine now. Thanks Vince!
Reply
#6

should i do this when setting my player's color(not on the /color command but on OnPlayerConnect) ??

pawn Код:
new color;
        color = pInfo[playerid][pColor];
        color <<= 8;
        color |= 0xFF;
        SetPlayerColor(playerid, color);
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)