SetPlayerMarkerForPlayer
#1

Hi,
I was reading on the wiki while I found this piece of code;
pawn Код:
// Make the players marker invisible to the player while keeping chat colour the same. Will only work correctly if SetPlayerColor has been used:
SetPlayerMarkerForPlayer( 42, 1, ( [b]GetPlayerColor( 1 ) & 0xFFFFFF00 ) );
 
// Make the players marker fully opaque (solid) to the player while keeping chat colour the same. Will only work correctly if SetPlayerColor has been used:
SetPlayerMarkerForPlayer( 42, 1, ([b] GetPlayerColor( 1 ) | 0x000000FF ) );
Now is my question what the bold parts do, I never saw such pawno code before...
Thanks

EDIT: The parts that should have been bold xd
Reply
#2

It's a HEX. Read THIS
Reply
#3

Thanks but I already knew what a HEX is but I can't figure what the & and | are...
Reply
#4

& - bitwise and
| - bitwise or

Explanations can be found in the whole net
Reply
#5

Quote:

// Make the players marker invisible to the player while keeping chat colour the same.
SetPlayerMarkerForPlayer( 42, 1, ( [b]GetPlayerColor( 1 ) & 0xFFFFFF00 ) );

// Make the players marker fully opaque (solid) to the player while keeping chat colour the same.
SetPlayerMarkerForPlayer( 42, 1, ([b] GetPlayerColor( 1 ) | 0x000000FF ) );

It does what the comments say.
The first line:
Код:
GetPlayerColor( 1 ) & 0xFFFFFF00
Takes the player's color and does a bitwise AND with 0xFFFFFF00.
This keeps the RGB (red, green, blue) part of the player's color but makes the Alpha (the last "00") 0, making the player's dot on the radar completely transparent.
If the player's color was 0x00FF00FF (green and full alpha), the color is set to 0x00FF0000 after this.

The second line:
Код:
GetPlayerColor( 1 ) | 0x000000FF
Takes the player's color and does a bitwise OR with 0x000000FF.
This keeps the player's color and sets the alpha to "FF", no matter what the alpha value of the player was before.
The player's dot will be fully opaque (non-transparent).
If the player's color was 0x00FF0000 (green and no alpha), the color is set to 0x00FF00FF after this.
Reply
#6

Quote:
Originally Posted by PowerPC603
Посмотреть сообщение
It does what the comments say.
The first line:
Код:
GetPlayerColor( 1 ) & 0xFFFFFF00
Takes the player's color and does a bitwise AND with 0xFFFFFF00.
This keeps the RGB (red, green, blue) part of the player's color but makes the Alpha (the last "00") 0, making the player's dot on the radar completely transparent.
If the player's color was 0x00FF00FF (green and full alpha), the color is set to 0x00FF0000 after this.

The second line:
Код:
GetPlayerColor( 1 ) | 0x000000FF
Takes the player's color and does a bitwise OR with 0x000000FF.
This keeps the player's color and sets the alpha to "FF", no matter what the alpha value of the player was before.
The player's dot will be fully opaque (non-transparent).
If the player's color was 0x00FF0000 (green and no alpha), the color is set to 0x00FF00FF after this.
Thanks a lot! This made it all clear!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)