color from mysql
#1

I have some colors in database which are stored as a string. Example: 0xB360FD33. I want to use it in gang zones. I have tryed to use HexToInt function, but it won't work.

GangZoneShowForAll(s3Zone_g_GangZones, color_from_mysql);
Reply
#2

They should be saved in a hex then loaded from as a hex.
Reply
#3

any example?
Reply
#4

Can you show us the error?
Reply
#5

i just can't load the color from my db corectly and then use it
Reply
#6

use sscanf for that

mysqlfetchrow or get field

new zone_color;
sscanf(colorStr,"x",zone_color);
GangZoneShowForAll(s3Zone_g_GangZones, zone_color);
Reply
#7

Save the colors as integers to begin with. Don't try to handle them as strings, because they're not. In your database, they will appear like -16777046 for red, but that's okay. It's just a different way of writing. For this same reason, you can put -1 as a color for client messages. This translates to 0xFFFFFFFF, i.e. pure white.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)