[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
#2

dont npc's already have themm.. but nice
Reply
#3

Quote:
Originally Posted by Kar
View Post
dont npc's already have themm.. but nice
nop. they dont
Reply
#4

isnt the nametag a thing which shows the id and the name
Reply
#5

pawn Code:
//you must have created a vehicle for it!
Don't post variables and other unknown things into tutorials when the reader doesn't knows them.

Some more explanation would be nice.
Reply
#6

Quote:
Originally Posted by Kar
View Post
isnt the nametag a thing which shows the id and the name
yes it is, but id does not work for bots!


Quote:
Originally Posted by Hiddos
View Post
pawn Code:
//you must have created a vehicle for it!
Don't post variables and other unknown things into tutorials when the reader doesn't knows them.

Some more explanation would be nice.
that info is in other tutorial Creating a new NPC(https://sampforum.blast.hk/showthread.php?tid=95034)
Reply
#7

the id works for me..

ShowNameTags(1) idk but i see them all
Reply
#8

This seems useles i mean npc`s already have names why do you need more info over them :/ but ...
Reply
#9

Nice azz.
Reply
#10

Thanks! found what i was looking for
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)