SA-MP Forums Archive
ShowPlayerNameTagForPlayer - A little help would be nice.. - 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: ShowPlayerNameTagForPlayer - A little help would be nice.. (/showthread.php?tid=551302)



ShowPlayerNameTagForPlayer - A little help would be nice.. - sgtph3n1x - 18.12.2014

So I have this issue "ShowPlayerNameTagForPlayer" I'm trying to turn off the nametag for the player that used the command, and so far it does indeed turn them off, but my problem is when another player teleports to me (admin) or uses a teleport, I'm not sure.. but I think when they join too my nametag is shown or shows back up, I know I'm missing something here..but I have no idea what, any help would be appreciative.

and before you send me to the SA-MP Wiki.. I've already been there and done that and finally gave up, and came here for help.

and there's nothing else to "ShowPlayerNameTagForPlayer" except these two commands.

Here is my code:

Код:
CMD:hidetag(playerid, params[])
{
	LoginCheck(playerid);
	LevelCheck(playerid, 4);

	for(new i=0; i<MAX_PLAYERS; i++)
	ShowPlayerNameTagForPlayer(i, playerid, false);
    SendClientMessage( playerid, COLOR_CHAT, "You have {AFAFAF}disabled{FF0060} your {AFAFAF}nametag{FF0060}, to re-enable it you must use {AFAFAF}/showtag{FF0060}." );
	return 1;

	}
	
CMD:showtag(playerid, params[])
{
	LoginCheck(playerid);
	LevelCheck(playerid, 4);

	for(new i=0; i<MAX_PLAYERS; i++)
	ShowPlayerNameTagForPlayer(i, playerid, true);
    SendClientMessage( playerid, COLOR_CHAT, "You have {AFAFAF}enabled{FF0060} your {AFAFAF}nametag{FF0060}." );
	return 1;

	}



Re: ShowPlayerNameTagForPlayer - A little help would be nice.. - Mic_H - 18.12.2014

PHP код:
new bool:Masked[MAX_PLAYERS];
public 
OnPlayerConnect(playerid)
{
    
Masked[playerid]=false;
    for(new 
i=0i<MAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(i))
        {
            if(
Masked[i]==true)
            {
                
ShowPlayerNameTagForPlayer(playeridifalse);
            }
        }
    }
}
public 
OnPlayerStreamIn(playeridforplayerid)
{
    if(
Masked[playerid]==true)
        
ShowPlayerNameTagForPlayer(forplayeridplayeridfalse);
    return 
1;
}
CMD:toggletag(playeridparams[])
{
    
LoginCheck(playerid);
    
LevelCheck(playerid4);
    if(
Masked[playerid]==false)//False = No Mask = Others can see.. 
    
{
        
Masked[playerid]=true;//True -> Mask -> Others cant see no more.. hurray!
        
for(new i=0i<MAX_PLAYERSi++)
        {
            if(
IsPlayerConnected(i))
                
ShowPlayerNameTagForPlayer(iplayeridfalse);
        }
        
SendClientMessageplayeridCOLOR_CHAT"You have {AFAFAF}disabled{FF0060} your {AFAFAF}nametag{FF0060}, to re-enable it you must use {AFAFAF}/showtag{FF0060}." );
    }
    else
    {
        
Masked[playerid]=false;
        for(new 
i=0i<MAX_PLAYERSi++)
        {
            if(
IsPlayerConnected(i))
                
ShowPlayerNameTagForPlayer(iplayeridtrue);
        }
        
SendClientMessageplayeridCOLOR_CHAT"You have {AFAFAF}enabled{FF0060} your {AFAFAF}nametag{FF0060}." );
    }
    return 
1;




Re: ShowPlayerNameTagForPlayer - A little help would be nice.. - sgtph3n1x - 26.12.2014

That surely solved it, thanks ALOT!


Re: ShowPlayerNameTagForPlayer - A little help would be nice.. - Abagail - 26.12.2014

Well; the reason why it wasn't working is that these things get reset when players stream in. So, to fix this you have to re-apply the name tag function when a masked player streams in for another player.