Posts: 723
Threads: 366
Joined: Jun 2016
Hi,
I'am using this function:
Код:
RGBAToARGB(color)
{
new alpha = color & 0xFF;
return ((color >>> 8) | (alpha << 24));
}
It's good function?
And then i want player let write hex code in dialog, when i format it like that
Код:
format( Writenhexcode, 20,"0x%sAA", inputtext );
Код:
new hexxxxx = HexToInt( Writenhexcode );
YOURHHEEX[ playerid ] = hexxxxx;
And then i use:
RGBAToARGB(YOURHHEEX[ playerid ]);
Posts: 1,208
Threads: 36
Joined: Apr 2015
If you need convert string RGB to RGBA (player color)
PHP код:
new hexxxxx = HexToInt(Writenhexcode); //example Writenhexcode is "FF6600" orange
YourColor[playerid] = RGBToRGBA(hexxxxx) + alpha; //you color is 0xFF660000 + alpha
RGB Include:
https://sampforum.blast.hk/showthread.php?tid=590770
Posts: 723
Threads: 366
Joined: Jun 2016
But my writen is good or no?
Posts: 1,208
Threads: 36
Joined: Apr 2015
in your example, the value will be in the format RGB
PHP код:
new hexxxxx = HexToInt(Writenhexcode); //FF6600
YOURHHEEX[playerid] = hexxxxx;
YOURHHEEX[playerid] = RGBAToARGB(YOURHHEEX[ playerid ]); // return 0x0000FF66 and should 0xFF660000
Posts: 723
Threads: 366
Joined: Jun 2016
new hexxxxx = HexToInt(Writenhexcode); //example Writenhexcode is "FF6600" orange
YourColor[playerid] = RGBToRGBA(hexxxxx) + alpha; //you color is 0xFF660000 + alpha
alpha what i need to write?
Posts: 1,208
Threads: 36
Joined: Apr 2015
mistake
Код:
RGBToRGBA(color,alpha);
Example:
PHP код:
YourColor[playerid] = RGBToRGBA(hexxxxx,0xFF);
Posts: 723
Threads: 366
Joined: Jun 2016
I don't want to download all that include, can you make little function RGBToRGBA ?
Posts: 1,208
Threads: 36
Joined: Apr 2015
PHP код:
#define RGBToRGBA(%0,%1) (((%0) << 8) | (%1))
Posts: 723
Threads: 366
Joined: Jun 2016
Because i want player write hex code and use it in SetObjectMaterialText, i can use?
Код:
format( blabla, 49,"Your color is:{%06x}COLOR", SAVEDHEXCODE[ playerid ] >>> 8);
SAVEDHEXCODE is
SAVEDHEXCODE[ playerid ] = HexToInt( inputtext );
Can i use that format to show color?
Posts: 1,208
Threads: 36
Joined: Apr 2015
PHP код:
SAVEDHEXCODE[ playerid ] = HexToInt( inputtext ); //string "FF6600" Int 0xFF6600 is RGB
format( blabla, 49,"Your color is:{%06x}COLOR", SAVEDHEXCODE[ playerid ]); //<--- Your color is:{FF6600}COLOR
For Set(Dynamic)ObjectMaterial
PHP код:
#define RGBToARGB(%0,%1) ((%0) | ((%1) << 24))
color = RGBToARGB(SAVEDHEXCODE[ playerid ],0xFF); //0xFFFF6600
For player color:
PHP код:
#define RGBToRGBA(%0,%1) (((%0) << 8) | (%1))
color = RGBToRGBA(SAVEDHEXCODE[ playerid ],0xFF); //0xFF6600FF