Hiding playerid's name tag upon crouching? -
rangerxxll - 04.03.2014
Hello. I'm looking to create a system where the player (playerid.) who is crouching will have their nametag hidden until they stand back up. I've looked at the wiki, but I'm not quite understanding. Here is what I have so far, which I know is incorrect. How would I do this?
Thanks.
pawn Код:
public OnPlayerUpdate(playerid)
{
if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_DUCK)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
ShowPlayerNameTagForPlayer(playerid, i, false);
}
}
return 1;
}
Re: Hiding playerid's name tag upon crouching? -
Nurgle4 - 04.03.2014
pawn Код:
public OnPlayerUpdate(playerid)
{
if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_DUCK)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
ShowPlayerNameTagForPlayer(playerid, i, false);
}
}
else
{
ShowPlayerNameTagForPlayer(playerid, i, true);
}
return 1;
}
I am on phone now but you need it to be only when he is crouching so you must set his name back...
Re: Hiding playerid's name tag upon crouching? -
Crayder - 04.03.2014
Place this under OnPlayerKeyState
pawn Код:
if(PRESSED(KEY_CROUCH))
{
foreach(Player, i)
{
if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_DUCK)
{
ShowPlayerNameTagForPlayer(playerid, i, false);
}
else
{
ShowPlayerNameTagForPlayer(playerid, i, true);
}
}
}
This is better than using OnPlayerUpdate, because of how often updates are it could set many loops at once.
Re: Hiding playerid's name tag upon crouching? -
rangerxxll - 04.03.2014
ShowPlayerNameTagForPlayer(playerid, i, false);
This will disable your tag for everyone, correct?
Re: Hiding playerid's name tag upon crouching? -
rangerxxll - 04.03.2014
It doesn't hide their names. I've defined "Press".
pawn Код:
#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(PRESSED(KEY_CROUCH))
{
foreach(Player, i)
{
if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_DUCK)
{
ShowPlayerNameTagForPlayer(playerid, i, false);
}
else
{
ShowPlayerNameTagForPlayer(playerid, i, true);
}
}
}
return 1;
}
Re: Hiding playerid's name tag upon crouching? -
Crayder - 04.03.2014
Quote:
Originally Posted by rangerxxll
It doesn't hide their names. I've defined "Press".
pawn Код:
#define PRESSED(%0) \ (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) { if(PRESSED(KEY_CROUCH)) { foreach(Player, i) { if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_DUCK) { ShowPlayerNameTagForPlayer(playerid, i, false); } else { ShowPlayerNameTagForPlayer(playerid, i, true); } } } return 1; }
|
Its the same exact code I use, and it works... ALSO: Just a hint but you can use the code below to hide their map icon from the radar, its the only thing i removed from the code i gave you above...
Quote:
SetPlayerColor(playerid, (GetPlayerColor(playerid) & 0xFFFFFF00));//To hide
SetPlayerColor(playerid, (GetPlayerColor(playerid) & 0xFFFFFFFF));//To show
|