Name above NPC
#1

How can I make that a name is above the NPC. The name I've added in ConnectNPC.
pawn Код:
//SPAWN//
if(IsPlayerNPC(playerid))
{
new npcname[MAX_PLAYER_NAME]
GetPlayerName(playerid, npcname, sizeof(npcname));
Is it with 3D Text or something? How works that?
Please help me!
Reply
#2

Код:
public OnPlayerConnect(playerid)
{
	if(IsPlayerNPC(playerid))
	{
		new npcname[MAX_PLAYER_NAME];
		GetPlayerName(playerid, npcname, sizeof(npcname));

		new Text3D: NPC_NameTag;
		NPC_NameTag = Create3DTextLabel(npcname,0xFFFFFFFF,0.0,0.0,0.0,20,0,1);
		Attach3DTextLabelToPlayer(NPC_NameTag, playerid, 0.0, 0.0, 1.0);
	}
	return 1;
}
Reply
#3

Thank you!

Do you know also how to make you see it from a longer distance?
and do you know how to get the ID of one NPC?
Reply
#4

Showing ID next to the name:

Код:
public OnPlayerConnect(playerid)
{
	if(IsPlayerNPC(playerid))
	{
		new npcname[MAX_PLAYER_NAME];
		new NameTagString[32];
		GetPlayerName(playerid, npcname, sizeof(npcname));
		format(NameTagString, sizeof(NameTagString), "%s (%d)", npcname, playerid);
		
		new Text3D: NPC_NameTag;
		NPC_NameTag = Create3DTextLabel(NameTagString,0xFFFFFFFF,0.0,0.0,0.0,20,0,1);
		Attach3DTextLabelToPlayer(NPC_NameTag, playerid, 0.0, 0.0, 1.0);
	}
	return 1;
}


Setting the draw distance:

Quote:

NPC_NameTag = Create3DTextLabel(NameTagString,0xFFFFFFFF,0.0,0.0 ,0.0,20,0,1);

Change the red number to anything else.
Reply
#5

Thank you!

How to get the ID of a NPC?
Reply
#6

Quote:
Originally Posted by CAR
Thank you!

How to get the ID of a NPC?
OnPlayerConnect has a playerid parameter.
Reply
#7

Yes, but I've got I timer because I want to spawn the same NPC with another name in my server
I've make a car and a name, but I can't put in the Timer: PutPlayerInVehicle(playerid, vehicleid);

Because I can't use playerid (when I use: for(new i = 0; i <= MAX_PLAYERS; i++), all the players go in that vehicle?)

(Can't they make in new version GetPlayerID(playername[], const name[]); or something :P)
Reply
#8

Then you need that:

Код:
new i;
new npcname[MAX_PLAYER_NAME];
for(i = 0; i < GetMaxPlayers(); i++)
{
	if(IsPlayerConnected(i) && IsPlayerNPC(i))
	{
		GetPlayerName(i, npcname, sizeof(npcname));
 		if(!strcmp(npcname,"HereComesTheName",true))
	 	{
	 		PutPlayerInVehicle(i, vehicleid);
	 		return 1;
	 	}
	}
}
Replace 'HereComesTheName' with your NPC's name.
Reply
#9

I send you my Timer, maybe it's easier then...
pawn Код:
public Taxis2()
{
    new TAXIN=0, TAXINM[MAX_PLAYER_NAME], CARN[128], CARNM;
    TAXIN++;
    if(TAXIN <= 10)
    {
        format(CARN, sizeof(CARN), "TAXIV2%d", TAXIN);
        format(TAXINM, sizeof(TAXINM), "Taxi2%d", TAXIN);
        CARNM = CARN[56];
        CARNM = CreateVehicle(420, -1988.075073, 127.980735, 27.317974, 180.540512, 6, 6, 1);
        ConnectNPC(TAXINM, "Taxi2");
    }
}
I make 10 same Taxi's: Taxi21, Taxi22, Taxi23, Taxi24, etc.
Reply
#10

[edit] nevermind..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)