Problem with ShowPlayerNameTagForPlayer
#1

Hi, I'm experiencing some difficulties. Here is my code:

pawn Код:
CMD:maskon(playerid, params[])
{
    if(pRegistered[playerid] == 0)
    for(new i = 0; i < MAX_PLAYERS; i ++)
    {
        ShowPlayerNameTagForPlayer(i, playerid, true);
    }
    SendClientMessage(playerid, 0xFFFFFFFF, "{FFCC00}Info: {FFFFFF}Your name is now hidden.");
    new string[200];
    format(string, sizeof(string), "{FFFF00}AdmWarning: {FFFFFF}%s has hidden his name.", pName[playerid]);
    for(new i = 0; i < MAX_PLAYERS; i ++)
    {
        if(PlayerData[i][pAdmin] > 0)
        {
            SendClientMessage(i, 0xFFFFFFFF, string);
        }
    }
    return 1;
}

CMD:maskoff(playerid, params[])
{
    if(pRegistered[playerid] == 0)
    for(new i = 0; i < MAX_PLAYERS; i ++)
    {
        ShowPlayerNameTagForPlayer(i, playerid, false);
    }
    SendClientMessage(playerid, 0xFFFFFFFF, "{FFCC00}Info: {FFFFFF}Your name is no longer hidden.");
    new string[200];
    format(string, sizeof(string), "{FFFF00}AdmWarning: {FFFFFF}%s has shown his name.", pName[playerid]);
    for(new i = 0; i < MAX_PLAYERS; i ++)
    {
        if(PlayerData[i][pAdmin] > 0)
        {
            SendClientMessage(i, 0xFFFFFFFF, string);
        }
    }
    return 1;
}
Now, when I go on to the game, if a certain player has ID 0, they can always see other people's names, even if they use [/maskon]. However, if a player does not have ID 0 and another player uses [/maskon], that other player's name disappears but for ID 0 it remains exposed.

Thanks.
Reply
#2

Try this:

pawn Код:
CMD:maskon(playerid, params[])
{
    if(pRegistered[playerid] == 0)
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        ShowPlayerNameTagForPlayer(i, playerid, 0);
    }
pawn Код:
CMD:maskoff(playerid, params[])
{
    if(pRegistered[playerid] == 0)
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        ShowPlayerNameTagForPlayer(i, playerid, 1);
    }
I'm not sure, if something wrong fix me..
Reply
#3

pawn Код:
CMD:maskon(playerid, params[])
{
    if(pRegistered[playerid])
    {
        new string[75];
        format(string, sizeof(string), "{FFFF00}AdmWarning: {FFFFFF}%s has hidden his name.", pName[playerid]);
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(!IsPlayerConnected(i)) continue;
            ShowPlayerNameTagForPlayer(i, playerid, 0);
            if(PlayerData[i][pAdmin]) SendClientMessage(i, 0xFFFFFFFF, string);
        }
        SendClientMessage(playerid, 0xFFFFFFFF, "{FFCC00}Info: {FFFFFF}Your name is now hidden.");
    }
    return 1;
}

CMD:maskoff(playerid, params[])
{
    if(pRegistered[playerid])
    {
        new string[75];
        format(string, sizeof(string), "{FFFF00}AdmWarning: {FFFFFF}%s has shown his name.", pName[playerid]);
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(!IsPlayerConnected(i)) continue;
            ShowPlayerNameTagForPlayer(i, playerid, 1);
            if(PlayerData[i][pAdmin]) SendClientMessage(i, 0xFFFFFFFF, string);
        }
        SendClientMessage(playerid, 0xFFFFFFFF, "{FFCC00}Info: {FFFFFF}Your name is no longer hidden.");
    }
    return 1;
}
It is recommended that you add something under OnPlayerSpawn so you can 'refresh' the hidden name, as it is often removed when a new player joins.
Reply
#4

Meh, instead of this:

pawn Код:
if(pRegistered[playerid] == 0) return 0;
I put this:

pawn Код:
if(pRegistered[playerid] == 0)
Thanks for the help anyway guys, I've not scripted for a few months now lol.
Reply
#5

Yeah that was confusing me, I wasn't sure whether the pRegistered = 0 was intentional or not, so I just put it as it was. I'd recommend that you use the code I've given above, because it saves some usage.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)