Hiding playerid's name tag upon crouching?
#1

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;
}
Reply
#2

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...
Reply
#3

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.
Reply
#4

ShowPlayerNameTagForPlayer(playerid, i, false);

This will disable your tag for everyone, correct?
Reply
#5

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;
}
Reply
#6

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

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)