NPC names - 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: NPC names (
/showthread.php?tid=380810)
NPC names -
Blasphemy - 27.09.2012
How to show a NPC name like normal players ingame?
Is there a function or a way to do it?
Thanks
Re: NPC names -
XtremeR - 27.09.2012
add this above OnGameModeInit
pawn Код:
new Text3D:NPC;//you can change "NPC" to whatever you want
Add this line under OnGameModeInit
pawn Код:
NPC = Create3DTextLabel("Bot_name_here",Color_here,0.0, 0.0,0.0,30.0,0);
Add this line under OnPlayerSpawn
pawn Код:
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(NPC, playerid, 0.0, 0.0, 0.0);
return 1;
}
If your NPC is in a vehicle it will look like this :
pawn Код:
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(NPC, playerid, 0.0, 0.0, 0.0);
PutPlayerInVehicle(playerid, NRG500, 0); //you must have created a vehicle for it!
return 1;
}
here you go
Re: NPC names -
.v - 27.09.2012
pawn Код:
if(IsPlayerNPC(playerid))
{
new npcname[MAX_PLAYER_NAME];
GetPlayerName(playerid, npcname, sizeof(npcname));
if(!strcmp(npcname, "YOURBOTNAME", true))
{
SetPlayerSkin(playerid, 45);
}
Re: NPC names -
Anak - 27.09.2012
follow above two posts