SA-MP Forums Archive
Save and load Hex (player colors) in BlueG MySQL R39! - 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: Save and load Hex (player colors) in BlueG MySQL R39! (/showthread.php?tid=562492)



Save and load Hex (player colors) in BlueG MySQL R39! - VenomMancer - 09.02.2015

Helo huys how to save and load my player color with MySQL ?
My tables name is `players` and `color` is column for save and load player colors,
pawn Код:
pInfo[playerid][Color] // My variabel for player color



Re: Save and load Hex (player colors) in BlueG MySQL R39! - Sime30 - 09.02.2015

Not sure but you could save it as a varchar , load it and store it into your variable and finally setplayercolor with your variable


Re: Save and load Hex (player colors) in BlueG MySQL R39! - VenomMancer - 09.02.2015

Sorry i did .
Thanks all


Re: Save and load Hex (player colors) in BlueG MySQL R39! - Vince - 09.02.2015

Colors are numbers. You only need a regular integer field. Only use conversion functions when the value needs to be converted from an input string (i.e. params from a command or dialog box inputtext).


Re: Save and load Hex (player colors) in BlueG MySQL R39! - PowerPC603 - 09.02.2015

As Vince said, colors are just numbers.
Color 0xFFFFFFFF is exactly the same as color -1.

It's just so we can read it easier.
Colors in hex are made up by red, green, blue and transparency values, each represented by 2 digits.

Take 0x12345678 for example.
The "12" represents the red value, "34" is green, "56" is blue and "78" is transparency.
The 0x tells the compiler that the following digits are hex-codes.

Each digit is a value from 0 to 15, where value above 10 are represented by A (10), B(11), C(12), D(13), E(14) and F(15).

The "12" isn't 12, as hex numbers don't work with base-10 value, they use base-16 values.

To convert to a decimal value:
(1 * 16^7) + (2 * 16^6) + (3 * 16^5) + (4 * 16^4) + (5 * 16^3) + (6 * 16^2) + (7 * 16^1) + (8 * 16^0)
= 268435456 + 33554432 + 3145728 + 262144 + 20480 + 1536 + 112 + 8
= 305419896

So value 0x12345678 equals integer number 305419896, which can be stored safely in an integer field.