[Tutorial] How to add a name tag over a NPC
#1

You must have a ready NPC(to make go to the link below)
https://sampforum.blast.hk/showthread.php?tid=95034

1st:
You must add this above OnGameModeInit

Code:
new Text3D:Botinfo;//you can change "Botinfo" to whatever you want
2nd:

Add this line under OnGameModeInit

Quote:

Botinfo = Create3DTextLabel("Bot_name_here",Colour_here,0.0, 0.0,0.0,30.0,0);

3rd

Add this line under OnPlayerSpawn

Code:
if(IsPlayerNPC(playerid)) //Checks if the player that just spawned is an NPC.
  {
    new npcname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, npcname, sizeof(npcname)); //Getting the NPC's name.
    if(!strcmp(npcname, "NPC_connect_name", true)) 
    {
      Attach3DTextLabelToPlayer(Botinfo, playerid, 0.0, 0.0, 0.0);
      return 1;
    }
If your NPC is in a vehicle it will look like this :

Code:
if(IsPlayerNPC(playerid)) //Checks if the player that just spawned is an NPC.
  {
    new npcname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, npcname, sizeof(npcname)); //Getting the NPC's name.
    if(!strcmp(npcname, "NPC_connect_name", true)) 
    {
      Attach3DTextLabelToPlayer(Botinfo, playerid, 0.0, 0.0, 0.0);
	  PutPlayerInVehicle(playerid, NRG500, 0); //you must have created a vehicle for it!
      return 1;
    }
And thats it! Hope it helped!
Reply if you have any questions...
Reply


Messages In This Thread
How to add a name tag over a NPC - by [MNC]Azz - 27.07.2010, 17:20
Re: How to add a name tag over a NPC - by Kar - 27.07.2010, 18:27
Re: How to add a name tag over a NPC - by [MNC]Azz - 27.07.2010, 18:28
Re: How to add a name tag over a NPC - by Kar - 27.07.2010, 18:58
Re: How to add a name tag over a NPC - by Hiddos - 27.07.2010, 19:23
Re: How to add a name tag over a NPC - by [MNC]Azz - 27.07.2010, 19:31
Re: How to add a name tag over a NPC - by Kar - 28.07.2010, 01:08
Re: How to add a name tag over a NPC - by Armin_Avdic - 28.07.2010, 16:55
Re: How to add a name tag over a NPC - by matthewdriftking - 28.07.2010, 18:57
Re: How to add a name tag over a NPC - by Bramblez - 16.09.2011, 01:02

Forum Jump:


Users browsing this thread: 1 Guest(s)