Nametag, apply it to everyone inside the vehicle.
#1

Hello guys, I'm pretty new to pawn, however through trial and error i manage to learn a lot.
However, i simply can't get this to work, so if you have the time, and wouldn't mind, I'd love to get a little hand understanding why it doesn't work.

Код:
if(!strcmp(cmd,"/hide",true))

{
	if(IsPlayerInAnyVehicle(playerid))
	
	{
		new caridnice = GetPlayerVehicleID(playerid);
		for(new i=0;i<MAX_PLAYERS;i++)
		
		{
			if(IsPlayerInVehicle(i, GetPlayerVehicleID(playerid)))
			
			{
				ShowPlayerNameTagForPlayer(i,playerid, 0);
				
			}
			ShowPlayerNameTagForPlayer(playerinfo[i][isadmin]>8,playerid, 1);
			
		}
		SendClientMessage(playerid,COLOR_GREY,"your nametag is now hidden");
		
	}
	else
	return 1;
	
}
To give you an idea of what i want to do:
I want to remove the nametag of everyone who's in the vehicle, including the driver.
Any help is appreciated.
Reply
#2

What's the problem, do you get error or doesn't it work in game?
Reply
#3

Quote:
Originally Posted by Klutty
What's the problem, do you get error or doesn't it work in game?
It doesn't turn out to work as indented ingame.

Well, it does, however only for the driver (his nametag is the only one getting hidden)
So what I'm trying to get done, is so it hides the nametag of everyone who's in the vehicle with use of the IsPlayerInVehicle.
Reply
#4

(a small bump)
Reply
#5

so what ur saying is when a player types /hide when he is in a vehicle it hides everyone's nametag for him only or everyone else can't see his nametag only?
Reply
#6

Quote:
Originally Posted by [B2K
Hustler ]
so what ur saying is when a player types /hide when he is in a vehicle it hides everyone's nametag for him only or everyone else can't see his nametag only?
What I'm saying is that it only hides the drivers nametag, where my intention is to get it to hide everyone who is in the car's nametag (so when someone in the car does /hide, it'll hide the nametags of everyone who's in the vehicle, for the rest of the server)
Reply
#7

Ok, the thing that you're asking for is very challenging for me. Nevertheless, i'll give it a go.
This should hide nametags for all the players in your vehicle for everyone else who is not in your car. If you are in the car when u type that same car as the player you will be able to see the player's nametag. So you need to ask someone outside of the car to tell u if they can see ur nametag.
pawn Код:
if(!strcmp(cmd,"/hide",true))
{
    if(IsPlayerInAnyVehicle(playerid))
    {
      new myvehicleid = GetPlayerVehicleID(playerid);
      for (new i = 0; i < MAX_PLAYERS+1; i++)
        {
            for (new x = 0; x < MAX_PLAYERS+1; x++)
            {
                if(x != i && IsPlayerConnected(x))
                {
                    if(!IsPlayerInVehicle(i, myvehicleid)
                    {
                      if(IsPlayerConnected(x) && IsPlayerConnected(i))
                      {
                        ShowPlayerNameTagForPlayer(x,i,0);
                        // or delete abve line and put this ShowPlayerNameTagForPlayer(i,x,0);
                        }
                    }
                }
            }
        }
        GameTextForPlayer(playerid,"~r~Nametags Hidden", 3000, 1);
        ShowPlayerNameTagForPlayer(playerinfo[i][isadmin]>8,playerid, 1);
        SendClientMessage(playerid,COLOR_GREY,"your nametag is now hidden");
    }
    else SendClientMessage(playerid,COLOR_GREY,"you need to be in a vehicle to use this command!");
    return 1;

}
This is untested. There might be a major flaw in this code, so nobody please start making issues, rather say why it would not work. My logic was lost half way through the code but it's worth a try. I also gave an alternative - please see the comments for ShowPlayerNameTagForPlayer.

Let us know.
Reply
#8

Thanks for your try Hunter.
It seems to have some failure somewhere, however as i have never made something like this before i can't really seem to sort it.

The alternative was the correct one, the one using the command's nametag was not being turned off however, that was easy to fix.
I'm not as advanced so halfway through it i seriously get off the rails.
Reply
#9

Bump, anyone able to help out?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)