SA-MP Forums Archive
[REP++] Color problem - Converting HEX - 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: [REP++] Color problem - Converting HEX (/showthread.php?tid=585610)



[REP++] Color problem - Converting HEX - buburuzu19 - 15.08.2015

Solved.


Re: [REP++] Color problem - Converting HEX - buburuzu19 - 15.08.2015

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

Sorry for x2 post.


Re: [REP++] Color problem - Converting HEX - Vince - 15.08.2015

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.


Re: [REP++] Color problem - Converting HEX - buburuzu19 - 15.08.2015

Solved.


Re: [REP++] Color problem - Converting HEX - Jefff - 15.08.2015

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));



Re: [REP++] Color problem - Converting HEX - Vince - 15.08.2015

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: