View Full Version : How to make 3PlayerTextLabel NameTag System

03/01/2016, 03:58 PM
Hello All

i want to make 3playertextlabel nametag system like this Max Williams not Max_Williams

Like True Roleplay Server.

03/01/2016, 04:20 PM
bits from my script - create a new label for each player
new PlayerText3D:PlayerLabel[SLOTS];
Attach label to player at the spawn (use some kind of variable to do it only once)

PlayerLabel[playerid] = Create3DTextLabel("Player's Label", 0xFFFFFFFF, x, y, z, drawdistance, vw, testlos);
Attach3DTextLabelToPlayer(PlayerLabel[playerid], playerid, x, y, z);
UpdatePlayerLabel(playerid); //custom function

And update it every time it's needed.

GetPlayerHealth(playerid, pHealth);
GetPlayerArmour(playerid, pArmour);
format(stc,sizeof(stc),"\n\n\n{BFBFBF}%s\n{FFFFFF}%.0f hp, %.0f armour", RemoveUnderScore(playerid), pHealth, pArmour);
Update3DTextLabelText(PlayerLabel[playerid], 0xFFFFFFFF, stc);

And don't forget to destroy the label when player is leaving the server.

03/01/2016, 04:22 PM
i want it without HP & Armour and are you sure the name without _ this?

03/01/2016, 04:25 PM
Then just remove hp/armour integers so only %s (string with name) will be left.
And i forgot to post the RemoveUnderScore stock, sorry. There you go:

stock RemoveUnderScore(playerid)
new name[MAX_PLAYER_NAME];
for(new i = 0; i < MAX_PLAYER_NAME; i++)
if(name[i] == '_') name[i] = ' ';
return name;

03/01/2016, 05:10 PM
Don't forget that you will need to hide the original SA-MP nametags by using the code below in your OnGameModeInit() callback.

public OnGameModeInit()
// This will fully disable all player nametags
// (including health and armour bars)