OnPlayerText Problem to new Functions ?
#1

New 0.3c function is " {RRGGBB}Text " in Message to Colored Text.. But PlayerColor is = 0xRRGGBBFF you know.
How to get PlayerColor 0xRRGGBBFF to RRGGBB ?

Код:
format(str, sizeof(str), "{%x}",GetPlayerColor(playerid));
format(MMM, sizeof(MMM),"{FFFFFF}[] %s%s : {FFFFFF}%s", playerid, str, oName, text);
This code doesn't work correctly The PlayerColor is ; 0x00F600F6 return is; F600F6 but correct return; 00F600

How can I do correct ? Sorry my bad english :/
Reply
#2

You need to shift player color 8 bits right to remove the alpha part, like this:
pawn Код:
format(str, sizeof(str), "{%x}", GetPlayerColor(playerid) >> 8);
If you wanna know how this works:
https://sampwiki.blast.hk/wiki/Binary
https://sampwiki.blast.hk/wiki/Hex
Reply
#3

or just
pawn Код:
format(str, sizeof(str), "{%06x}", GetPlayerColor(playerid));
Reply
#4

Thanks
Reply
#5

sdfsdfsf
Reply
#6

oops! sorry for the above reply.
Reply
#7

Jo thanks guys. I didn't know you could add '%' strings in the {} colors.
Reply
#8

Or:
pawn Код:
format(str, sizeof(str), "{%06x}", GetPlayerColor(playerid) >>> 8);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)