How to check, if color is black.
#1

Hi.

How to check it ?
Thanks!
Reply
#2

https://sampwiki.blast.hk/wiki/GetPlayerColor
Reply
#3

I'm know from it.

But i need check, if black. Ex: 1, 500, 658 <- This is not valid colors.
Reply
#4

pawn Код:
SetPlayerColor( playerid, COLOR_BLACK );

if( GetPlayerColor( playerid ) == COLOR_BLACK ) {
    SendClientMessage( playerid, -1, "Your color is black (no racist :p). " );
}
Reply
#5

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


Forum Jump:


Users browsing this thread: 1 Guest(s)