Mysql Load/Save Colors - 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: Mysql Load/Save Colors (
/showthread.php?tid=410235)
Mysql Load/Save Colors -
Richie© - 24.01.2013
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?
Re: Mysql Load/Save Colors -
Vince - 24.01.2013
Treat it like any other normal integer value. The hexadecimal number system is just a way of representation.
Re: Mysql Load/Save Colors -
Richie© - 24.01.2013
So when setting the colour i can do this?
pawn Код:
TeamInfo[i][tColour] = strval(inputtext);
Re: Mysql Load/Save Colors -
Vince - 24.01.2013
If you're converting from user input then you're probably better off using sscanf.
Re: Mysql Load/Save Colors -
Richie© - 24.01.2013
Ok, it worked out fine now. Thanks Vince!
Re: Mysql Load/Save Colors -
AiRaLoKa - 17.05.2014
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);