PDA

View Full Version : New name tags


HondaCBR
28/12/2011, 03:06 AM
I want to use 3d text for name tags and disable the default ones. Would this work?

Also the name needs to be visible for everyone (15) dis next to you, but not visible to yourself.

public OnPlayerConnect(playerid)
{
new plname2[MAX_PLAYER_NAME];
new nameformat[30];
new PlayerText3D:playertextid;
new Float:X, Float:Y, Float:Z;
GetPlayerName(playerid, plname2, sizeof(plname2));
GetPlayerPos(playerid,X,Y,Z);
format(nameformat,sizeof(nameformat),"%s",plname2);
playertextid = CreatePlayer3DTextLabel(playerid,nameformat,COLOR_ WHITE,X,Y,Z,15.0);
Attach3DTextLabelToPlayer(Text3D:playertextid, playerid, 0.0, 0.0, 0.7);


Will this work?

Steven82
28/12/2011, 03:32 AM
Try it. But on your Z coordinate, you need to add more than GetPlayerPos value. If you add to the Z cord, it will raise above your head, and if you lower it, it will of course lower.

HondaCBR
28/12/2011, 03:38 AM
I posted it because I cant try it right now, no one will come online to come on server at this time :P ill try it tomorrow, just check through if you can If i didnt make any mistakes.

MP2
28/12/2011, 04:00 AM
It's best to use chat bubbles, as they move up as players get further away - 3D text labels do not.

http://wiki.sa-mp.com/wiki/SetPlayerChatBubble

HondaCBR
28/12/2011, 08:50 AM
Ok this code works fine:

The name comes up, but it doesnt move with the player, it stays at spawn.

public OnPlayerSpawn(playerid)
{
new plname2[MAX_PLAYER_NAME];
new nameformat[30];
new PlayerText3D:playertextid;
new Float:X, Float:Y, Float:Z;
GetPlayerName(playerid, plname2, sizeof(plname2));
GetPlayerPos(playerid,X,Y,Z);
format(nameformat,sizeof(nameformat),"%s",plname2);
for(new i = 0; i < MAX_PLAYERS; i++)
{
playertextid = CreatePlayer3DTextLabel(i,nameformat,COLOR_WHITE,X ,Y,Z,15.0);
}
Attach3DTextLabelToPlayer(Text3D:playertextid, playerid, 0.0, 0.0, 2.7);
}

HondaCBR
28/12/2011, 09:16 AM
Ok I fixed it.

This works now, so if anyone wants to use it I recommend it. Its better because you could do:
format(nameformat,sizeof(nameformat),"%s\nSeat Belts",plname2); //for example
So when you get in a car and type /sb, a thing comes underneath your name with that information, and there are many more uses like Strength: %d, if you have a gym workout script.

So it works finr, I recommend it, thx for everyone who helped.


public OnPlayerSpawn(playerid)
{
SetPlayerColor(playerid,COLOR_WHITE);
new plname2[MAX_PLAYER_NAME];
new nameformat[30];
new Text3D:playertextid;
new Float:X, Float:Y, Float:Z;
GetPlayerName(playerid, plname2, sizeof(plname2));
GetPlayerPos(playerid,X,Y,Z);
format(nameformat,sizeof(nameformat),"%s",plname2);
playertextid = Create3DTextLabel(nameformat,COLOR_WHITE,X,Y,Z+1.1 ,15,0,0);
Attach3DTextLabelToPlayer(playertextid, playerid, 0.0, 0.0, 1.1);
}