ShowPlayerNameTagForPlayer [Help]
#1

Hello, how can i make it so that ShowPlayerNameTagForPlayer effects everyone?
My Current Code
Код:
 CMD:hidenames(playerid, params[])
{
    if (PlayerInfo[playerid][pAdmin] >= 6) {
        foreach(Player, i) {
        ShowPlayerNameTagForPlayer(playerid, i, false);
        }
        new string[128];
		format(string, sizeof(string), "[ADMIN] %s has set everyones names to hidden.", GetPlayerNameEx(playerid));
		ABroadCast(COLOR_LIGHTRED, string, 2);
    }

    else {
        SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
    }
    return 1;
}
I Will +Rep on whoever helps me (:
Reply
#2

So yours code dosen't work?
I don't Understand

Try this

pawn Код:
CMD:hidenames(playerid, params[])
{
    if (PlayerInfo[playerid][pAdmin] >= 6)
    {
        foreach(Player, i)
        {
        ShowPlayerNameTagForPlayer(playerid, i, false);
        new string[128];
        format(string, sizeof(string), "[ADMIN] %s has set everyones names to hidden.", GetPlayerNameEx(playerid));
        ABroadCast(COLOR_LIGHTRED, string, 2);
        }
    }
    else
    {
        SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
    }
    return 1;
}
Reply
#3

Do you mean, when you type the command, everyone will not be able to see eachothers name? If that is what you want, here it is:

pawn Код:
CMD:hidenames(playerid, params[])
{
    if (PlayerInfo[playerid][pAdmin] >= 6) {
        foreach(Player, i) {
            ShowPlayerNameTagForPlayer(i, i, false);
        }
        new string[128];
        format(string, sizeof(string), "[ADMIN] %s has set everyones names to hidden.", GetPlayerNameEx(playerid));
        ABroadCast(COLOR_LIGHTRED, string, 2);
    }
    else return SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
    return 1;
}
You had playerid where it was suppose to be i, as only the playerid that typed it would be effected. I simply simplified the stuff and added the i for you.

And also, a little tip, I'd suggest creating a variable or something that would allow you to incorporate it into the script, so for example, when the player spawns, if the variable is 1 (or true) it would set his name hidden, or if it is 0, would keep it as it is.

Not tested, as I do not use foreach nor do I use ShowPlayerNameTagForPlayer.

@Fires, well, I think he is asking how to make it so it EFFECTS everyone, as he stated, so that everyone can't see eachothers name. The code he provided simply removed names for just the playerid that typed it, so I simply edited it a little and made it so everyone sees no nametag for eachother.
Reply
#4

Uhm, that command hides every name of the server for the person that typed the command only. ( playerid )

This should help:

pawn Код:
ShowPlayerNameTagForPlayer(i, i, false);
Reply
#5

I Just Tryed All Of The Above And When I Use The Command I Can't See The Player Tags But Others Can See Them. :#
Reply
#6

Did the players join after you used the command? If so, add a variable to the command that then is checked when a player spawns or what-not and if it is true, or 1, it will ShowPlayerNameTagForPlayer and remove their tags.

example:

pawn Код:
new bool:isnametagshidden;//Top of the script, global variable

//Command (used with ZCMD)
CMD:hidenames(playerid, params[])
{
    if (PlayerInfo[playerid][pAdmin] >= 6) {
        foreach(Player, i) {
            ShowPlayerNameTagForPlayer(i, i, false);
        }
        isnametagshidden = true;
        new string[128];
        format(string, sizeof(string), "[ADMIN] %s has set everyones names to hidden.", GetPlayerNameEx(playerid));
        ABroadCast(COLOR_LIGHTRED, string, 2);
    }
    else return SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
    return 1;
}

//Add this when you first spawn the player (possibly after login or register or what-not
//Something like this

if(isnametagshidden == true)
{
    foreach(Player, i) {
        ShowPlayerNameTagForPlayer(i, i, false);
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)