Names with 3DTextLabels
#1

Hi, I deleted the normal name tags (ShowNameTags(0)), and I used the 3DTextLabels (with Incognito's Streamer Plugin) to have the Name Tags. But in some Times the names change. For example Player2 has the name of Player1 and Player1 doesn't have the name.

This is the function:

Код:
enum PA {
Text3D: pnlabel
}
new PlayerAccount[MAX_PLAYERS][PA];
OnPlayerConnect:

Код:
if(!IsPlayerNPC(playerid))
		{
			PlayerAccount[playerid][pnlabel] = CreateDynamic3DTextLabel(PlayerAccount[playerid][Name],0xDCEAE9FF, 0.0, 0.0, 0.0, 15, playerid,-1, 1);
		}
OnGameModeInit:
Код:
SetTimer("DrugTime", 9000, true);
OnPlayerDisconnect:
Код:
DestroyDynamic3DTextLabel(PlayerAccount[playerid][pnlabel]);
Код:
forward DrugTime();
public DrugTime()
{

 	for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(PlayerAccount[i][Logged])
        {
            new Float:health, namedstring[60];
            GetPlayerHealth(i,health);
            format(namedstring, 55, "%s", PlayerAccount[i][Name]);
            if(PlayerAccount[i][wearingmask] == 1){
                    format(namedstring, sizeof(namedstring), "Sconosciuto #%d",PlayerAccount[i][ID]);
			}
			UpdateDynamic3DTextLabelText(PlayerAccount[i][pnlabel], 0xDCEAE9FF, namedstring);
            if (health >= 65.0 && Drinking[i]==0)
            {
                SetPlayerDrunkLevel(i, 0);
                if(PlayerAccount[i][wearingmask] == 1){

                    format(namedstring, sizeof(namedstring), "Sconosciuto #%d",PlayerAccount[i][ID]);
				}
                UpdateDynamic3DTextLabelText(PlayerAccount[i][pnlabel], 0xDCEAE9FF, namedstring);
            }
            else if (health <= 65.0 && health > 45 && Antidolor[i]==0)
            {
                if(PlayerAccount[i][wearingmask] == 1){

                    format(namedstring, sizeof(namedstring), "Sconosciuto #%d",PlayerAccount[i][ID]);
				}
                UpdateDynamic3DTextLabelText(PlayerAccount[i][pnlabel], 0xFFDC00FF, namedstring);
            }
            else if (health <= 45.0 && health > 30 && Antidolor[i] == 0)
            {
                if(random(1)==0){
                if(!IsPlayerInAnyVehicle(i))
                {
                    ApplyAnimation(i,"SWEET","Sweet_injuredloop",4.0,1,0,0,0,6000,1); //anim injured
                }
                if(PlayerAccount[i][wearingmask] == 1){

                    format(namedstring, sizeof(namedstring), "Sconosciuto #%d",PlayerAccount[i][ID]);
				}
                UpdateDynamic3DTextLabelText(PlayerAccount[i][pnlabel], 0xFF5000FF, namedstring);
                SetPlayerHealth(i, health-1);
                PlayerActionMessage(i,15.0,"non sta bene.");
                SetPlayerDrunkLevel(i, 5000);}
            }
            else if (health <= 30.0 && Antidolor[i] == 0)
            {
                if(random(1)==0){
                if(!IsPlayerInAnyVehicle(i))
                {
                    ApplyAnimation(i,"CRACK","crckdeth2",4.1,0,1,1,1,1,1);
                }
                if(PlayerAccount[i][wearingmask] == 1){

                    format(namedstring, sizeof(namedstring), "Sconosciuto #%d",PlayerAccount[i][ID]);
				}
                UpdateDynamic3DTextLabelText(PlayerAccount[i][pnlabel], 0xFF1400FF, namedstring);
                SetPlayerHealth(i, health-2.5);
                PlayerActionMessage(i,15.0,"non sta bene.");
                SetPlayerDrunkLevel(i, 10000);}
            }
            if(ADuty[i])
			{
				format(namedstring, sizeof(namedstring), "Admin %s", PlayerAccount[i][Name]);
				UpdateDynamic3DTextLabelText(PlayerAccount[i][pnlabel], 0x5189F0FF, namedstring);
			}
			else if(HelperDuty[i])
			{
			    format(namedstring, sizeof(namedstring), "Helper %s", PlayerAccount[i][Name]);
				UpdateDynamic3DTextLabelText(PlayerAccount[i][pnlabel], 0x91FFADFF, namedstring);
			}
         }
    }
Some words are italian, but doesn't matter because they are only string
Reply
#2

Anyone can help me?
Reply
#3

What I have to do?
Reply
#4

Try this code, if it's not working print some of the strings, you're setting the 3DTextLabel to and see if it set's the string value correctly, if not find out what causes it not to set the string "correct". Also you can use this define I added to the start of the code to remove all the forwards and make hopefully make your scripting a little bit more comfortable. PS, next time use [ PAWN ] [ / PAWN ] tags instead of code, makes it a little more easier to read

pawn Код:
#define publicEx%0(%1) forward%0(%1); public%0(%1)
publicEx DrugTime()
{

    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(PlayerAccount[i][Logged])
        {
            new Float:health, namedstring[60];
            GetPlayerHealth(i, health);
            format(namedstring, sizeof(namedstring), "%s", PlayerAccount[i][Name]);
           
            if(PlayerAccount[i][wearingmask] == 1){
                    format(namedstring, sizeof(namedstring), "Sconosciuto #%d", PlayerAccount[i][ID]);
                    UpdateDynamic3DTextLabelText(PlayerAccount[i][pnlabel], 0xDCEAE9FF, namedstring);
            }

            if (health >= 65.0 && Drinking[i]==0)
            {
                SetPlayerDrunkLevel(i, 0);
                if(PlayerAccount[i][wearingmask] == 1){

                    format(namedstring, sizeof(namedstring), "Sconosciuto #%d",PlayerAccount[i][ID]);
                    UpdateDynamic3DTextLabelText(PlayerAccount[i][pnlabel], 0xDCEAE9FF, namedstring);
                }
            }
            else if (health <= 65.0 && health > 45 && Antidolor[i]==0)
            {
                if(PlayerAccount[i][wearingmask] == 1){

                    format(namedstring, sizeof(namedstring), "Sconosciuto #%d", PlayerAccount[i][ID]);
                    UpdateDynamic3DTextLabelText(PlayerAccount[i][pnlabel], 0xFFDC00FF, namedstring);
                }
            }
            else if (health <= 45.0 && health > 30 && Antidolor[i] == 0)
            {
                if(random(1)==0){
                    if(!IsPlayerInAnyVehicle(i))
                    {
                        ApplyAnimation(i,"SWEET","Sweet_injuredloop",4.0,1,0,0,0,6000,1); //anim injured
                    }
                    if(PlayerAccount[i][wearingmask] == 1)
                    {
                        format(namedstring, sizeof(namedstring), "Sconosciuto #%d",PlayerAccount[i][ID]);
                        UpdateDynamic3DTextLabelText(PlayerAccount[i][pnlabel], 0xFF5000FF, namedstring);
                    }
                    SetPlayerHealth(i, health-1);
                    PlayerActionMessage(i,15.0,"non sta bene.");
                    SetPlayerDrunkLevel(i, 5000);
                }
            }
            else if (health <= 30.0 && Antidolor[i] == 0)
            {
                if(random(1)==0){
                    if(!IsPlayerInAnyVehicle(i))
                    {
                        ApplyAnimation(i,"CRACK","crckdeth2",4.1,0,1,1,1,1,1);
                    }
                    if(PlayerAccount[i][wearingmask] == 1){

                        format(namedstring, sizeof(namedstring), "Sconosciuto #%d",PlayerAccount[i][ID]);
                        UpdateDynamic3DTextLabelText(PlayerAccount[i][pnlabel], 0xFF1400FF, namedstring);
                    }
                    SetPlayerHealth(i, health-2.5);
                    PlayerActionMessage(i,15.0,"non sta bene.");
                    SetPlayerDrunkLevel(i, 10000);
                }
            }
            if(ADuty[i])
            {
                format(namedstring, sizeof(namedstring), "Admin %s", PlayerAccount[i][Name]);
                UpdateDynamic3DTextLabelText(PlayerAccount[i][pnlabel], 0x5189F0FF, namedstring);
            }
            else if(HelperDuty[i])
            {
                format(namedstring, sizeof(namedstring), "Helper %s", PlayerAccount[i][Name]);
                UpdateDynamic3DTextLabelText(PlayerAccount[i][pnlabel], 0x91FFADFF, namedstring);
            }
         }
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)