[REP++] Color problem - Converting HEX
#1

Solved.
Reply
#2

Does anybody know what is the problem and what should i do ?

Sorry for x2 post.
Reply
#3

More like sorry for x2 thread. I've told you once before in your other thread that you should store colors as numbers in your database because that will make everything loads easier. 0x is simply a notion for the compiler so it can distinguish from a variable and treat it as a number. 0x must never be formatted into a string.
Reply
#4

Solved.
Reply
#5

Change to
pawn Код:
stock ConvertToARGB(const gColor[], bool:ARGB = true, alpha = 0xFF)
{
    new color[11],color_int;
    color = "0x";
    strcat(color, gColor);
    sscanf(color, "x", color_int);
    color_int = (color_int * 256) + alpha;
    return ARGB ? RGBAtoARGB(color_int) : color_int;
}
if you want RGBA instead of ARGB set in function bool:ARGB to false

pawn Код:
format(string,sizeof(string),"COLOR: %i",ConvertToARGB(MafiaInfo[i][turfColor], false));
Reply
#6

Quote:
Originally Posted by buburuzu19
Посмотреть сообщение
I can't store colors because my system it's made for players to enter an HEX color , and i don't know how to convert a HEX color into a number's one.
You have already answered your own question:

Quote:
Originally Posted by buburuzu19
Посмотреть сообщение
pawn Код:
sscanf(color, "x", color_int);
Use that on inputtext or params or whatever players use to enter colors.

And oh:

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)