How to check, if color is black. - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How to check, if color is black. (
/showthread.php?tid=259640)
How to check, if color is black. -
kurta999 - 05.06.2011
Hi.
How to check it ?
Thanks!
Re: How to check, if color is black. -
Famalamalam - 05.06.2011
https://sampwiki.blast.hk/wiki/GetPlayerColor
Re: How to check, if color is black. -
kurta999 - 05.06.2011
I'm know from it.
But i need check, if black. Ex: 1, 500, 658 <- This is not valid colors.
Re: How to check, if color is black. -
Mean - 05.06.2011
pawn Код:
SetPlayerColor( playerid, COLOR_BLACK );
if( GetPlayerColor( playerid ) == COLOR_BLACK ) {
SendClientMessage( playerid, -1, "Your color is black (no racist :p). " );
}
Re: How to check, if color is black. -
Amit_B - 05.06.2011
pawn Код:
stock hex2rgba(hex,&r,&g,&b,&a) r = (hex >> 24) & 0x000000FF, g = (hex >> 16) & 0x000000FF, b = (hex >> 8) & 0x000000FF, a = hex & 0x000000FF;
using this function you can check if a color is similiar to any other color. for example:
pawn Код:
public OnPlayerSpawn(playerid)
{
new r, g, b, a;
rgba2hex(GetPlayerColor(playerid),r,g,b,a);
if(r == 0 && g == 0 && b == 0) // Black is R=0 B=0 G=0
{
// ...
}
}
Note: it works only for 0,0,0 black. There are a lot of more types of black with another numbers, if you need to detect every type of black, you should check if the sum of the three variables above (rgb) is smaller than 15 (I guess). This should work.