hex to RGBA?
#9

Quote:
Originally Posted by Nero_3D
Посмотреть сообщение
sscanf, you can use it for any string to something converting
https://github.com/Y-Less/sscanf/wiki/%22h%22-Specifier
pawn Код:
new hex;
sscanf(params, "h", hex);
// checking if the value is only between 0 and 0xFFFFFF
if(0 <= hex <= 0xFFFFFF) {
    // adding the full alpha (0xFF) in front of it
    hex |= 0xFF << 24;
}
Okay here's my dialog:
For example if my input is "FFFF00" the HEX will become FFFFFF00 without the 0x at the beginning and the color of the object wouldn't change either.

pawn Код:
if(response)
                {
                    new hex, matmodel, txdname[45], texturename[45], color;
                    if(isnull(inputtext) || sscanf(inputtext, "h", hex))
                        return RedNoticeEx(playerid, "Invalid HEX color."), ShowTextureColorChange(playerid, FMatSlot[playerid]);
                    hex |= 0xFF << 24;
                    SCMEx(playerid, hex, "%h", hex);
                    new object = Furniture[FHouse[playerid]][FSlot[playerid]][fObject];
                    GetDynamicObjectMaterial(object, FMatSlot[playerid], matmodel, txdname, texturename, color, 45, 45);
                    SetDynamicObjectMaterial(object, FMatSlot[playerid], matmodel, txdname, texturename, hex);
                    ShowTextureColorChange(playerid, FMatSlot[playerid]);
                }
Reply


Messages In This Thread
hex to RGBA? - by Albon - 11.02.2015, 20:51
Re: hex to RGBA? - by Vince - 11.02.2015, 20:55
Re: hex to RGBA? - by Dignity - 11.02.2015, 20:56
Re: hex to RGBA? - by Albon - 11.02.2015, 23:18
Re: hex to RGBA? - by Jefff - 11.02.2015, 23:42
Re: hex to RGBA? - by Albon - 12.02.2015, 00:08
AW: hex to RGBA? - by Nero_3D - 12.02.2015, 00:27
Re: hex to RGBA? - by PaulDinam - 12.02.2015, 00:47
Re: AW: hex to RGBA? - by Albon - 12.02.2015, 01:04
AW: Re: AW: hex to RGBA? - by Nero_3D - 12.02.2015, 01:42

Forum Jump:


Users browsing this thread: 1 Guest(s)