SA-MP Forums Archive
3DTextLabel doesn't disappear when being deleted. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: 3DTextLabel doesn't disappear when being deleted. (/showthread.php?tid=430051)



3DTextLabel doesn't disappear when being deleted. - Denying - 12.04.2013

Hey everybody, at first I would like to say thank you for actually reading this.

Alright, so I have the following code:
pawn Code:
CMD:hduty(playerid, params[])
{
    if(PlayerInfo[playerid][Helper] == false) return SendClientMessage(playerid, COLOR_ERROR, "ERROR: You are not authorized to perform this command!");
    GetPlayerName(playerid, aname, sizeof(aname));
    kreplace(aname, '_', ' ');
    if(PlayerInfo[playerid][hduty] == 0)
    {
        format(str, sizeof(str), "Helper %s is now on duty, use /ask if you need any server related help.", aname);
        SendClientMessageToAll(COLOR_LIGHTGREEN, str);
        PlayerInfo[playerid][hduty] = 1;
        SetPlayerColor(playerid, COLOR_PLAYER_ADUTY);
        hdutytext[playerid] = Create3DTextLabel("[HELPER DUTY]", 0xD90707FF, 30.0, 40.0, 50.0, 40.0, 0);
        Attach3DTextLabelToPlayer(hdutytext[playerid], playerid, 0.0, 0.0, 0.3);

    }
    else if(PlayerInfo[playerid][hduty] == 1)
    {
        format(str, sizeof(str), "** Helper %s has gone off helper duty.", aname);
        SendClientMessageToAll(0xDE2626FF, str);
        PlayerInfo[playerid][hduty] = 0;
        if(PlayerInfo[playerid][Tier] == 0) SetPlayerColor(playerid, COLOR_PLAYER_TIER_ZERO);
        if(PlayerInfo[playerid][Faction] == 1 && PlayerInfo[playerid][Tier] != 0) SetPlayerColor(playerid, COLOR_PLAYER_SINDACCO);
        if(PlayerInfo[playerid][Faction] == 0) SetPlayerColor(playerid, COLOR_WHITE);
        Delete3DTextLabel(hdutytext[playerid]);
    }
    return 1;
}
The 3DText ID is being created as a global one.
Well, as you can see I'm deleting this when the player is going off duty, and it worked perfectly on my localhost, but when I get it on my host.. I can't get it to work. ( Never tested it with more than 1 player on my localhost )
And well, I think it works when one player goes on duty and off duty, but when there are two.. it doesn't work.


Any ideas?


Re: 3DTextLabel doesn't disappear when being deleted. - Pottus - 12.04.2013

I know, 3DTextLabels are very buggy when you start attaching them to players when this starts to happen you will get multiple labels on a person no labels, labels not deleting etc I advise not using them like this. You've actually done nothing wrong it's a SAMP bug I've pulled my hair out over this before, tried a dozen different ways but the 3D Labels still persist to screw up whats more is I've seen this happen on a lot of other servers so my conclusion it has to be a bug.


Re: 3DTextLabel doesn't disappear when being deleted. - Denying - 12.04.2013

Oh, I see - thank you very much for providing me with this information.


Re: 3DTextLabel doesn't disappear when being deleted. - Pottus - 12.04.2013

I do have a good alternative suggestion, you could make two plane objects and apply text to them "[HELPER DUTY]" then use the old AttachObjectToPlayer() to put them on your chest and back. If I remember correctly you'll need to use OnPlayerStreamIn() and reattach them when a player streams in though.


Re: 3DTextLabel doesn't disappear when being deleted. - Denying - 12.04.2013

Mhm.. I'll check it out.
Thank you for the help, you deserve and have been given a reputation point. Thank you.

EDIT: For some reason I can not give you a reputation point, but I will as soon as I can.