Show player name tag..
#1

Hi !

I created a new server, and there is a class "NINJA"

But I want this class not to be seen by other classes, only by other "NINJAS".

So, in "OnPlayerSpawn", I did this :

if(gTeam[playerid] == NINJA) {
ShowPlayerNameTagForPlayer(gTeam[playerid] = LAMBDA, gTeam[playerid] = NINJA, false);


But doesn't work.. Help me !!
Reply
#2

Hi, don't use it with OnPlayerSpawn.
Player nametag is renewed every time a player is streamed in. Instead, use the public OnPlayerStreamIn(playerid, forplayerid). Simply check if both playerid and forplayerid are ninjas, and if not, then hide the nametag for the player.
Reply
#3

Thx for the answer.

I don't have my script in front of me but let's check if I understood.

OnPlayerStreamIn(playerid, forplayerid)
{
if(playerid == gTeam[playerid] = NINJA && forplayerid == gTeam[playerid] = LAMBDA)
{

ShowPlayerNameTagForPlayer(playerid, showplayerid, false);

}

else if(playerid == gTeam[playerid] = NINJA && forplayerid == gTeam[playerid] = NINJA)
{

ShowPlayerNameTagForPlayer(playerid, showplayerid, true);
}

}



Reply
#4

pawn Код:
public OnPlayerStreamIn(playerid, forplayerid)
{
     for(new i = 0; i < MAX_PLAYERS; i++)
     if(gTeam[playerid] == NINJA)
     {
            if(gTeam[i] == NINJA && playerid != i)
            {
                   // playerid is a ninja, "i" is not a ninja, hide playerid's tag in here.
                   // PS: I changed forplayerid to a loop so it won't bug with extensive lag, don't bitch about it.
            }
     }
     return 1;
}
Reply
#5

Thank you Sandiel & Martin !!

I've put comments in your code, can you tell me if I understood ? I'm not on my computer so I can't test the code... Sorry to annoy you with that, but I'm too impatient !

Код:
public OnPlayerStreamIn(playerid, forplayerid)
{
     for(new i = 0; i < MAX_PLAYERS; i++)
     if(gTeam[playerid] == NINJA)    // gTeam[playerid] represents me ?
     {
            if(gTeam[i] == NINJA && playerid != i) // gTeam[i] represents another player and we check if the player id of this other player does not match with mine ?
            {
                   // Show NameTags
                    ShowPlayerNameTagForPlayer(playerid, i, true);
            }
            
            else if(gTeam[i] == LAMBDA ) // Is it good to put it ?
            {
                  // Hide NameTags ?
                  ShowPlayerNameTagForPlayer(playerid, i, false);


            }


     }
     return 1;
}
Reply
#6

Quote:
Originally Posted by Sandiel
Посмотреть сообщение
pawn Код:
public OnPlayerStreamIn(playerid, forplayerid)
{
     for(new i = 0; i < MAX_PLAYERS; i++)
     if(gTeam[playerid] == NINJA)
     {
            if(gTeam[i] == NINJA && playerid != i)
            {
                   // Both of them are ninjas, code here.
            }
     }
     return 1;
}
What? Your code makes zero sense, why is the loop there?
pawn Код:
public OnPlayerStreamIn(playerid, forplayerid)
{
     if(gTeam[playerid] == NINJA && gTeam[forplayerid] == NINJA)
     {
          // Both of them are ninjas, code here.
     }
     return 1;
}
Reply
#7

Quote:
Originally Posted by Mmartin
Посмотреть сообщение
What? Your code makes zero sense, why is the loop there?
pawn Код:
public OnPlayerStreamIn(playerid, forplayerid)
{
     if(gTeam[playerid] == NINJA && gTeam[forplayerid] == NINJA)
     {
          // Both of them are ninjas, code here.
     }
     return 1;
}
It's better to loop for other players other than using the forplayerid parameter, because sometimes, while lagging, it does not register the forplayerid, basically printing that it doesn't even exist, it happened to me once with 480 ping, so yeah.
Reply
#8

I edited my message ( up ). Can you read it please ?

Thx for the help guys
Reply
#9

Just remove the loop, what Sandiel is describing is total nonsense. The only condition you need there is the one I already wrote in the post above, since nametags are shown by default, you only need to hide them if both aren't ninjas. So just edit the condition in my script to "gTeam[playerid] == NINJA && gTeam[forplayerid] != NINJA", and use function to hide the nametag in {brackets}
Reply
#10

Roger that thx
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)