SA-MP Forums Archive
HexColor, converting - 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: HexColor, converting (/showthread.php?tid=624384)



HexColor, converting - saffierr - 15.12.2016

I've done some research and I've seen several answers but I'm still not sure on how to create a good functional /setcolor [ID] [Hex] cmd, it's about the HexCode.
I've seen things with RGB, I've seen things with 255, and so on... you can mention them all, but after all I'm hoping for some help. I've got no code til so far, I hope that's not an issue.


Re: HexColor, converting - oktokt1 - 15.12.2016

Can you tell me example for Hex color ??
Like if u want to set my color then /setcolor 0 (??)


Re: HexColor, converting - saffierr - 15.12.2016

Ofcourse I can give you an example.
PHP код:
"Usage: /setcolor 0 FF00DD" 
Like that.


Re: HexColor, converting - oMa37 - 15.12.2016

use sscanf.


Re: HexColor, converting - saffierr - 15.12.2016

Quote:
Originally Posted by oMa37
Посмотреть сообщение
use sscanf.
Lol, I know, but that wasn't my question... My question was how I'm supposed to script that when I do: "FF00DD" the player's colour becomes that colour.


Re: HexColor, converting - SickAttack - 15.12.2016

Quote:
Originally Posted by saffierr
Посмотреть сообщение
Lol, I know, but that wasn't my question... My question was how I'm supposed to script that when I do: "FF00DD" the player's colour becomes that colour.
Literally the same answer.

pawn Код:
new id, color;
sscanf(params, "ux", id, color);



Re: HexColor, converting - saffierr - 15.12.2016

I've tried it, but it's being strange.
Whenever I do, /setcolor 0 FF00DD (Which is supposed to be Pink) the player's colour is being set as green?
Any idea?


Re: HexColor, converting - AbyssMorgan - 15.12.2016

PHP код:
new idcolor;
sscanf(params"ux"idcolor);
SetPlayerColor(id,(color << 8) | 0xFF); //0xFF is alpha 



Re: HexColor, converting - oktokt1 - 15.12.2016

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
Literally the same answer.

pawn Код:
new id, color;
sscanf(params, "ux", id, color);
Код:
new id, color;
sscanf(params, "ux", id, color);
SetPlayerColor(id,color);
Check SetPlayerColor to learn about it.


Re: HexColor, converting - Dayrion - 16.12.2016

Quote:
Originally Posted by AbyssMorgan
Посмотреть сообщение
PHP код:
new idcolor;
sscanf(params"ux"idcolor);
SetPlayerColor(id,(color << 8) | 0xFF); //0xFF is alpha 
I still don't understand how << (or >>) works.
Код:
main()
{
	new a = 3;
	printf("%b", a << 1);
	printf("%b", a << 0b1);
	printf("%b & %b", 3, 4);
}
Код:
[02:55:38] 110
[02:55:38] 110
[02:55:38] 11 & 100