How change color transperent?
#1

Hi,

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

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

So alpha i need write transperent like 55 44 11 ?
Reply
#4

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

So if i want 30 proc. how it look?
Reply
#6

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

What mean 0x4C, can i write just 76.5 ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)