SetPlayerMarkerForPlayer - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: SetPlayerMarkerForPlayer (
/showthread.php?tid=204348)
[SOLVED by PowerPC603] SetPlayerMarkerForPlayer -
Nameless303 - 29.12.2010
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
Re: SetPlayerMarkerForPlayer -
TopAz07 - 29.12.2010
It's a HEX. Read
THIS
Re: SetPlayerMarkerForPlayer -
Nameless303 - 29.12.2010
Thanks but I already knew what a HEX is but I can't figure what the & and | are...
Re: SetPlayerMarkerForPlayer -
Nero_3D - 29.12.2010
& - bitwise and
| - bitwise or
Explanations can be found in the whole net
Re: SetPlayerMarkerForPlayer -
PowerPC603 - 29.12.2010
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.
Re: SetPlayerMarkerForPlayer -
Nameless303 - 29.12.2010
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!