SA-MP Forums Archive
[Help] HEX To HTML? - 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: [Help] HEX To HTML? (/showthread.php?tid=569189)



[Help] HEX To HTML? - Equality - 28.03.2015

hey someone here got a stock for making a pawn hex color to html color?
exmple:

0x2B7997FF > 2B7997
0xA6921CFF > A6921C
0xE8D671FF > E8D671


Re: [Help] HEX To HTML? - nicholasramdhan - 28.03.2015

https://sampwiki.blast.hk/wiki/Hex_colours
(Put 0x in front of the code)


Re: [Help] HEX To HTML? - zaibaslr2 - 28.03.2015

Код:
stock GetHTMLColor(hex[])
{
        if(strlen(hex) != 10) return print("Invalid hex code");
	new html[7];
	strmid(html,hex,2,8);
	return html;
}
Try this, didn't test tho.


Respuesta: Re: [Help] HEX To HTML? - CuervO - 28.03.2015

Quote:
Originally Posted by zaibaslr2
Посмотреть сообщение
Код:
stock GetHTMLColor(hex[])
{
        if(strlen(hex) != 10) return print("Invalid hex code");
	new html[7];
	strmid(html,hex,2,8);
	return html;
}
Try this, didn't test tho.
Hexes are not a string, and that would be returning the color as a string.

See y_colors for more info


Re: Respuesta: Re: [Help] HEX To HTML? - Equality - 28.03.2015

Quote:
Originally Posted by CuervO
Посмотреть сообщение
Hexes are not a string, and that would be returning the color as a string.

See y_colors for more info
already read that, but i couldnt make such stock you know...
im just hoping that someone over here will help me.


Re: [Help] HEX To HTML? - Vince - 28.03.2015

Logical shift right by 8 bits (1 byte) to get rid off the alpha. Display using %06x in format.
pawn Код:
format(output, sizeof(output), "The color is %06x", color >>> 8);