Nametags - Questions -
BrainDamaged - 12.07.2018
Hi, I would like to use it in mode (
https://sampforum.blast.hk/showthread.php?tid=651314), but can it be improved in terms of performance?
How can I edit it as in picture 2
Re: Nametags - Questions -
BrainDamaged - 13.07.2018
Bump
Re: Nametags - Questions -
ItsRobinson - 13.07.2018
PHP код:
forward UpdateNametag();
public UpdateNametag()
{
foreach(new i : Player)
{
if(IsPlayerConnected(i))
{
new nametag[128], playername[MAX_PLAYER_NAME], Float:armour, Float:health;
GetPlayerArmour(i, armour);
GetPlayerHealth(i, health);
GetPlayerName(i, playername, sizeof(playername));
format(nametag, sizeof(nametag), "{%06x}%s {FFFFFF}(%i)\n{FF8282}HP: %f{FFFFFF} - AR: %f", GetPlayerColor(i) >>> 8, playername, i, floatround(health, floatround_round), floatround(armour, floatround_round));
UpdateDynamic3DTextLabelText(cNametag[i], 0xFFFFFFFF, nametag);
}
}
}
I think that will work, just replace the one from the guys script with the one above.
Not tested.
Re: Nametags - Questions -
J0sh... - 13.07.2018
Performance is amazing when you loop with a timer with no reason.
not that it matters anyway
Re: Nametags - Questions -
Jefff - 13.07.2018
Quote:
Originally Posted by ItsRobinson
PHP код:
forward UpdateNametag();
public UpdateNametag()
{
foreach(new i : Player)
{
if(IsPlayerConnected(i))
{
new nametag[128], playername[MAX_PLAYER_NAME], Float:armour, Float:health;
GetPlayerArmour(i, armour);
GetPlayerHealth(i, health);
GetPlayerName(i, playername, sizeof(playername));
format(nametag, sizeof(nametag), "{%06x}%s {FFFFFF}(%i)\n{FF8282}HP: %f{FFFFFF} - AR: %f", GetPlayerColor(i) >>> 8, playername, i, floatround(health, floatround_round), floatround(armour, floatround_round));
UpdateDynamic3DTextLabelText(cNametag[i], 0xFFFFFFFF, nametag);
}
}
}
I think that will work, just replace the one from the guys script with the one above.
Not tested.
|
You dont need IsPlayerConnected part in foreach, and also i have question to all how to create
https://sampwiki.blast.hk/wiki/ShowPlayerNameTagForPlayer to this include with Create3dTextLabel ?
Re: Nametags - Questions -
ItsRobinson - 13.07.2018
Quote:
Originally Posted by Jefff
|
I just copied the code the guy made and changed the formatted 3dtext :P
And if you're going to use this as the only nametag system you have (i.e. completely remove the default nametags)
Just add this under OnGameModeInit
PHP код:
ShowNameTags(0);
This will completely disable the nametags, if you want to make it tog-able (I see a lot servers using tog-able for admins so they can still use the nametag cleo)
Under OnPlayerConnect
PHP код:
foreach(new i : Player)
{
ShowPlayerNameTagForPlayer(playerid, i, 0);
}
Then you can allow players to turn it on (anyway you wish) like this
PHP код:
foreach(new i : Player)
{
ShowPlayerNameTagForPlayer(playerid, i, 1);
}
Simple as that.
Re: Nametags - Questions -
Jefff - 13.07.2018
Nope you need create own ShowPlayerNameTagForPlayer function with Create3dTextLabel
Re: Nametags - Questions -
ItsRobinson - 13.07.2018
Quote:
Originally Posted by Jefff
Nope you need create own ShowPlayerNameTagForPlayer function with Create3dTextLabel
|
Oh sorry, I miss understood what you meant, I thought you was talking about the default nametags, well yeah in that case, you would have to create a way to toggle it on and off within the filterscript OR you can port the code from the filterscript into your main script.
Re: Nametags - Questions -
Jefff - 13.07.2018
I know that i need create, but i dont have any clue how to do it simply ;d
Re: Nametags - Questions -
ItsRobinson - 13.07.2018
Quote:
Originally Posted by Jefff
I know that i need create, but i dont have any clue how to do it simply ;d
|
Very Simple.
PHP код:
new tagToggle[MAX_PLAYERS]; //global variable
//code such as a command to turn the nametags on/off
if(tagToggle[playerid] == 1) //off
{
foreach(new i : Player)
{
cNametag[i] = CreateDynamic3DTextLabel("Loading nametag...", 0xFFFFFFFF, 0.0, 0.0, 0.1, NT_DISTANCE, .attachedplayer = i, .testlos = 1);
tagToggle[i] = 0;
}
}
else if(tagToggle[playerid] == 0) //on
{
foreach(new i : Player)
{
Delete3DTextLabel(cNametag[i]);
tagToggle[i] = 1;
}
}
PHP код:
forward UpdateNametag();
public UpdateNametag()
{
foreach(new i : Player)
{
if(tagToggle[i] == 1) return 1;
//rest of the code after that....
}
That is how you would do it, make sure under OnPlayerDisconnect, you set tagToggle[playerid] = 0;