SA-MP Forums Archive
How change color transperent? - 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: How change color transperent? (/showthread.php?tid=620718)



How change color transperent? - MerryDeer - 02.11.2016

Hi,

I have GetPlayerColor, i want to make it half transperent, how to do it?


Re: How change color transperent? - X337 - 02.11.2016

Код:
SetPlayerMarkerVisibility(playerid, alpha = 0xFF)
{
    new oldcolor, newcolor;
 
    alpha = clamp(alpha, 0x00, 0xFF); // if an out-of-range value is supplied we'll fix it here first
    oldcolor = GetPlayerColor(playerid); // get their color - Note: SetPlayerColor must have been used beforehand
 
    newcolor = (oldcolor & ~0xFF) | alpha; // first we strip of all alpha data (& ~0xFF) and then we replace it with our desired value (| alpha)
    return SetPlayerColor(playerid, newcolor); // returns 1 if it succeeded, 0 otherwise
}
https://sampwiki.blast.hk/wiki/Colors_List


Re: How change color transperent? - MerryDeer - 02.11.2016

So alpha i need write transperent like 55 44 11 ?


Re: How change color transperent? - X337 - 02.11.2016

Yeah, in example if you want to set player marker visibility to 50%, you can use
Код:
SetPlayerMarkerVisibility(playerid, 0x7F);



Re: How change color transperent? - MerryDeer - 02.11.2016

So if i want 30 proc. how it look?


Re: How change color transperent? - X337 - 02.11.2016

You can use 255 * (percentage) in calculator and convert it to hex.
Example :
If you want 30%, you can use calculator and count "255 * 0.3" and convert it into hex.
Код:
SetPlayerMarkerVisibility(playerid, 0x4C); // 30% (255 * 0.3 = 76.5 (4c))
SetPlayerMarkerVisibility(playerid, 51); // 20% (255 * 0.2 = 51)



Re: How change color transperent? - MerryDeer - 02.11.2016

What mean 0x4C, can i write just 76.5 ?