SA-MP Forums Archive
Name tag for bots - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Name tag for bots (/showthread.php?tid=276898)



[SOLVED]Name tag for bots - grand.Theft.Otto - 15.08.2011

Does anyone have a code for a name tag that can be used for bots that is just like the player name tag over their heads ?

Thanks.


Re: Name tag for bots - Jeffry - 15.08.2011

pawn Код:
BotLabel = Create3DTextLabel("Bot_Name", 0x00FF00FF, 0.0, 0.0, 0.0, 100.0, 0, 0);
Attach3DTextLabelToPlayer(BotLabel, playerid, 0.0, 0.0, 1);
That's what I'm using.


Re: Name tag for bots - grand.Theft.Otto - 15.08.2011

Thanks, but I want it to get the bot's name and id. I currently have this:

pawn Код:
if(!strcmp(npcname, "AirCanada", true))
{  
    new string[128], Float:X, Float:Y, Float:Z, PlayerText3D:playertextid;
    GetPlayerPos(playerid, X, Y, Z);
    GetPlayerName(playerid,npcname,sizeof(npcname));

    format(string,128,"%s (%d)",npcname,playerid);
    playertextid = CreatePlayer3DTextLabel(playerid,string,COLOR_WHITE,X,Y,Z,40.0);
    return 1;
}
Nothing shows up above my the bot in-game though, whats wrong with this ?


Re: Name tag for bots - Libra_PL - 15.08.2011

You need also to attach the 3d text label to bot...
EDIT: And change from CreatePlayer3d... To Create3d... Because you are creating label that will be shown only for bot (?)


Re: Name tag for bots - Jeffry - 15.08.2011

pawn Код:
if(!strcmp(npcname, "AirCanada", true))
{  
    new string[128], Float:X, Float:Y, Float:Z, Text3D:playertextid;
    GetPlayerPos(playerid, X, Y, Z);
    GetPlayerName(playerid,npcname,sizeof(npcname));

    format(string,128,"%s (%d)",npcname,playerid);
    playertextid = Create3DTextLabel(playerid,string,COLOR_WHITE,X,Y,Z,40.0);
    Attach3DTextLabelToPlayer(playertextid, playerid, 0.0, 0.0, 1);
    return 1;
}
Jeffry


Re: Name tag for bots - grand.Theft.Otto - 15.08.2011

@Jeffry, when I use that, it interferes with other text labels, for example I have a text label named Ammunation infront of one of my ammunation stores and it attaches the Ammunation label above the bot. If I disable all text labels except for the one you have in the code above, nothing shows above the bot :/


Re: Name tag for bots - iPLEOMAX - 15.08.2011

pawn Код:
//Global:
new Text3D:NPCLabel[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    if(IsPlayerNPC(playerid))
    {
        new str[32], name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof name);
        format(str, sizeof str, "%s (%i)",name,playerid);
        NPCLabel[playerid] = Create3DTextLabel(str, 0xFFFFFFFF, 0,0,0, 50, 0, true);
        Attach3DTextLabelToPlayer(NPCLabel[playerid], playerid, 0,0,0.4);
    }
    return true;
}

public OnPlayerDisconnect(playerid)
{
    if(IsPlayerNPC(playerid)) Delete3DTextLabel(NPCLabel[playerid]);
    return true;   
}



Re: Name tag for bots - grand.Theft.Otto - 15.08.2011

I know for sure this should work, but it's not :S

Maybe something is interfering again but not sure


Re: Name tag for bots - iPLEOMAX - 15.08.2011

Quote:
Originally Posted by grand.Theft.Otto
Посмотреть сообщение
I know for sure this should work, but it's not :S

Maybe something is interfering again but not sure
Yes, something prolly bugging it.

Mine:



Re: Name tag for bots - grand.Theft.Otto - 15.08.2011

Yup lol, that's exactly what I wanted.

So the code you gave me is the result in the picture?

EDIT:

I fixed it lol, the solution was to remove the attach3dtext etc... from OnPlayerSpawn and add your code under OnPlayerConnect, pleox.

Thanks everyone !


Re: Name tag for bots - Kingunit - 15.08.2011

Quote:
Originally Posted by grand.Theft.Otto
Посмотреть сообщение
Yup lol, that's exactly what I wanted.

So the code you gave me is the result in the picture?
Yes it does. You are sure you did everything correct?


Re: Name tag for bots - iPLEOMAX - 15.08.2011

Check the virtual world of your NPC and your player. Because the label is created in virtual world "0".


Re: Name tag for bots - grand.Theft.Otto - 15.08.2011

Haha, thanks I edited my last post because I fixed it but the solution was to remove the attach3dtext etc... from OnPlayerSpawn and add your code under OnPlayerConnect, pleox.

Thanks everyone !