Nametags - Questions
#1

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

Reply
#2

Bump
Reply
#3

PHP код:
forward UpdateNametag();
public 
UpdateNametag()
{
    foreach(new 
Player)
    {
        if(
IsPlayerConnected(i))
        {
            new 
nametag[128], playername[MAX_PLAYER_NAME], Float:armourFloat:health;
            
GetPlayerArmour(iarmour);
            
GetPlayerHealth(ihealth);
            
GetPlayerName(iplayernamesizeof(playername));
            
format(nametagsizeof(nametag), "{%06x}%s {FFFFFF}(%i)\n{FF8282}HP: %f{FFFFFF} - AR: %f"GetPlayerColor(i) >>> 8playernameifloatround(healthfloatround_round), floatround(armourfloatround_round));
            
UpdateDynamic3DTextLabelText(cNametag[i], 0xFFFFFFFFnametag);
        }
    }

I think that will work, just replace the one from the guys script with the one above.

Not tested.
Reply
#4

Performance is amazing when you loop with a timer with no reason.

not that it matters anyway
Reply
#5

Quote:
Originally Posted by ItsRobinson
Посмотреть сообщение
PHP код:
forward UpdateNametag();
public 
UpdateNametag()
{
    foreach(new 
Player)
    {
        if(
IsPlayerConnected(i))
        {
            new 
nametag[128], playername[MAX_PLAYER_NAME], Float:armourFloat:health;
            
GetPlayerArmour(iarmour);
            
GetPlayerHealth(ihealth);
            
GetPlayerName(iplayernamesizeof(playername));
            
format(nametagsizeof(nametag), "{%06x}%s {FFFFFF}(%i)\n{FF8282}HP: %f{FFFFFF} - AR: %f"GetPlayerColor(i) >>> 8playernameifloatround(healthfloatround_round), floatround(armourfloatround_round));
            
UpdateDynamic3DTextLabelText(cNametag[i], 0xFFFFFFFFnametag);
        }
    }

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

Quote:
Originally Posted by Jefff
Посмотреть сообщение
You dony 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 ?
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 Player)
{
    
ShowPlayerNameTagForPlayer(playeridi0);

Then you can allow players to turn it on (anyway you wish) like this

PHP код:
foreach(new Player)
{
    
ShowPlayerNameTagForPlayer(playeridi1);

Simple as that.
Reply
#7

Nope you need create own ShowPlayerNameTagForPlayer function with Create3dTextLabel
Reply
#8

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

I know that i need create, but i dont have any clue how to do it simply ;d
Reply
#10

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 
Player)
    {
        
cNametag[i] = CreateDynamic3DTextLabel("Loading nametag..."0xFFFFFFFF0.00.00.1NT_DISTANCE, .attachedplayer i, .testlos 1);
    
tagToggle[i] = 0;
    }
}
else if(
tagToggle[playerid] == 0//on
{
    foreach(new 
Player)
    {
        
Delete3DTextLabel(cNametag[i]);
        
tagToggle[i] = 1;
    }

PHP код:
forward UpdateNametag();
public 
UpdateNametag()
{
    foreach(new 
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;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)