[Help] HEX To HTML?
#1

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

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

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

Код:
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.
Reply
#4

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
Reply
#5

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.
Reply
#6

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


Forum Jump:


Users browsing this thread: 1 Guest(s)