SA-MP Forums Archive
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: Name Tag?? (/showthread.php?tid=603321)



Name Tag?? - VenusDarkX - 21.03.2016

I am looking for some code can hide or show name of the player if they enter vehicles. Sorry about bad English!!! (If it's bad )


Re: Name Tag?? - NaS - 21.03.2016

Say a player enters a vehicle, and his tag should not be shown to all others (and re-shown on exitting the veh.) you have to do this:

Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER) for(new i = 0; i < MAX_PLAYERS; i ++) if(IsPlayerConnected(i) && playerid != i) ShowPlayerNameTagForPlayer(playerid, i, 0);
    if(newstate != PLAYER_STATE_DRIVER && newstate != PLAYER_STATE_PASSENGER) for(new i = 0; i < MAX_PLAYERS; i ++) if(IsPlayerConnected(i) && playerid != i) ShowPlayerNameTagForPlayer(playerid, i, 1);
}
You could add some optimization to the loops above, like checking if the players are streamed in for each other or something, but it's not doing much anyways.

However, if I remember correctly, this gets reset if a player streams out and in again, so you have to repeat this in OnPlayerStreamIn (if the first of the 2 players is in a vehicle). But test it first.


Re: Name Tag?? - VenusDarkX - 22.03.2016

Thanks for help me!!!!