SA-MP Forums Archive
Show player name tag.. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Show player name tag.. (/showthread.php?tid=449944)



Show player name tag.. - kurt225 - 10.07.2013

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 !!


Re: Show player name tag.. - Mmartin - 10.07.2013

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.


Re: Show player name tag.. - kurt225 - 10.07.2013

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);
}

}






Re: Show player name tag.. - Sandiel - 10.07.2013

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;
}



Re: Show player name tag.. - kurt225 - 10.07.2013

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;
}



Re: Show player name tag.. - Mmartin - 10.07.2013

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;
}



Re: Show player name tag.. - Sandiel - 10.07.2013

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.


Re: Show player name tag.. - kurt225 - 10.07.2013

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

Thx for the help guys


Re: Show player name tag.. - Mmartin - 11.07.2013

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}


Re: Show player name tag.. - kurt225 - 11.07.2013

Roger that thx