Hexadecimal colors in my script? (and DB)
#4

As stated above, colors are integers, that are usually represented in hex form.

Solving your problem depends on how you are setting the color variables, be it from a string retrieved from a command, or a #define, or whatever.

you can convert a hex string to integer using sscanf2
https://sampforum.blast.hk/showthread.php?tid=120356
pawn Код:
CMD:testcolor(playerid,params[])
{
     new color;
     if(!sscanf(params,"h",color))
     {
           ....
     }
}
I'm not sure if sscanf2 checks for the correct samp hex color format ( I presume it doesn't ) so if you are retrieving the colors from a command, I would check the format with something like this.
pawn Код:
if(strlen(params) == 10 && !strcmp(tmp,"0x",true,2)) //success
[edit] oops I just saw you already knew this, oh well good luck.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)