Name tag for bots
#1

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.
Reply
#2

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.
Reply
#3

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 ?
Reply
#4

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 (?)
Reply
#5

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
Reply
#6

@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 :/
Reply
#7

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;   
}
Reply
#8

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

Maybe something is interfering again but not sure
Reply
#9

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:
Reply
#10

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 !
Reply
#11

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?
Reply
#12

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

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 !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)