Save and load Hex (player colors) in BlueG MySQL R39!
#1

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
Reply
#2

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

Sorry i did .
Thanks all
Reply
#4

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).
Reply
#5

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)