Question about 3DTextLabel's.
#9

This needs to be a global variable:
pawn Код:
new Text3D:PlayerID[MAX_PLAYERS];
Currently every time you use '/healthbars' it gives PlayerID[playerid] a new value (which is 0 by default). So when you use /healthbars to delete the text, it will always delete Label ID 0. What you need to do is this:

pawn Код:
new HealthBars[MAX_PLAYERS]; //At the top of your script.
new Text3D:PlayerID[MAX_PLAYERS]; //At the top of your script.

CMD:healthbars(playerid)
{
    if(!HealthBars[playerid])
    {
        //new string[25]. Why? You're not formatting the string at all, so it will just be empty...
        new string[25], Float:Xpos, Float:Ypos, Float:Zpos; //X, Y and Z isn't necessary.
        GetPlayerPos(playerid, Xpos, Ypos, Zpos); //This isn't necessary.
        PlayerID[playerid] = Create3DTextLabel(string, 0xFFFFFFFF, Xpos, Ypos, (Zpos + 1.34), 20.0, 0);
        //Because you are attaching the label to a player, you can create the label anywhere like 0.0, 0.0, 0.0. It won't matter.
        Attach3DTextLabelToPlayer(PlayerID[playerid], playerid, 0.0, 0.0, 0.14);
    }
    else Delete3DTextLabel(PlayerID[playerid]);
    HealthBars[playerid] = (HealthBars[playerid]) ? (0) : (1);
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    if(HealthBars[playerid]) Delete3DTextLabel(PlayerID[playerid]);
    //Rest of code...
}

public OnPlayerConnect(playerid)
{
    HealthBars[playerid] = 0;
    //Rest of code..
}
Reply


Messages In This Thread
Question about 3DTextLabel's. [UNSOLVED] - by $Marco$ - 11.06.2014, 16:00
Re: Question about 3DTextLabel's. - by Rittik - 11.06.2014, 16:10
Re: Question about 3DTextLabel's. - by $Marco$ - 11.06.2014, 16:11
Re: Question about 3DTextLabel's. - by Rittik - 11.06.2014, 16:18
Re: Question about 3DTextLabel's. - by $Marco$ - 11.06.2014, 16:32
Re: Question about 3DTextLabel's. - by $Marco$ - 11.06.2014, 17:38
Re: Question about 3DTextLabel's. - by $Marco$ - 11.06.2014, 22:03
Re: Question about 3DTextLabel's. - by Richie© - 11.06.2014, 22:16
Re: Question about 3DTextLabel's. - by Threshold - 11.06.2014, 23:00

Forum Jump:


Users browsing this thread: 4 Guest(s)