SA-MP Forums Archive
Text Label won't destroy/appears randomly on players. - 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: Text Label won't destroy/appears randomly on players. (/showthread.php?tid=619163)



Text Label won't destroy/appears randomly on players. - Dokins - 14.10.2016

http://prnt.sc/cpexr6

Players seem to walk around randomly like the above screenshot.
pawn Код:
forward DeathAnim(playerid);
public DeathAnim(playerid)
{
    TogglePlayerControllable(playerid, 0);
    ApplyAnimation(playerid, "KNIFE", "KILL_Knife_Ped_Die", 4.1, 0, 1, 1, 1, 0, 1);
    new string[128];
    format(string, sizeof(string), "D E A D\nB O D Y");
    DeathLabel[playerid] = CreateDynamic3DTextLabel(string, COLOUR_REALRED, 0.0, 0.0, -0.5, 50.0, playerid, INVALID_VEHICLE_ID);
    return 1;
}
Creates no problem at all.

Most of the time it destroys.

I clear it like this when an admin does /aheal, when a player disconnects.
pawn Код:
UpdateDynamic3DTextLabelText(DeathLabel[giveplayerid], -1, " ");
    DestroyDynamic3DTextLabel(DeathLabel[giveplayerid]);
pawn Код:
//Full /aheal.
CMD:aheal(playerid, params[])
{
    if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");

    new giveplayerid;
    if(AdminLevel[playerid] < 1) return SendClientMessage(playerid, COLOUR_GREY, "You are not authorized to use this command.");
    if(sscanf(params, "u", giveplayerid)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /aheal [playerid or name]");
    if(!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, COLOUR_GREY, "That player is not connected.");

    new string[128];
    format(string, sizeof(string), "Your injuries have been healed by Admin %s.",GetNameEx(playerid));
    SendClientMessage(giveplayerid, COLOUR_LIGHTBLUE, string);
    format(string, sizeof(string), "You have healed %s's injuries.",GetNameEx(giveplayerid));
    SendClientMessage(playerid, COLOUR_LIGHTBLUE, string);
    KillTimer(BleedingTime[giveplayerid]);
    BleedingTime[giveplayerid] = -1;
    PlayerIsDead[giveplayerid] = 0;
    LArmBl[giveplayerid] = 0;
    LArmBr[giveplayerid] = 0;
    RArmBl[giveplayerid] = 0;
    RArmBr[giveplayerid] = 0;
    TorsoBl[giveplayerid] = 0;
    LLegBr[giveplayerid] = 0;
    LLegBl[giveplayerid] = 0;
    RLegBr[giveplayerid] = 0;
    RLegBl[giveplayerid] = 0;
    GroinBl[giveplayerid] = 0;
    Headshot[giveplayerid] = 0;
    for(new x; x < 10; x++)
    {
        BodyPartDamage[giveplayerid][x] = 0;
    }
   
    TextDrawHideForPlayer(giveplayerid,RLegBlab);
    TextDrawHideForPlayer(giveplayerid,LLegBlab);
    TextDrawHideForPlayer(giveplayerid,RArmBlab);
    TextDrawHideForPlayer(giveplayerid,LArmBlab);
    TextDrawHideForPlayer(giveplayerid,RLegBlTD);
    TextDrawHideForPlayer(giveplayerid,LLegBlTD);
    TextDrawHideForPlayer(giveplayerid,RArmBlTD);
    TextDrawHideForPlayer(giveplayerid,LArmBlTD);
    TextDrawHideForPlayer(giveplayerid,GroinBlTD);
    TextDrawHideForPlayer(giveplayerid,TorsoBlTD);
    TextDrawHideForPlayer(giveplayerid,HeadshotTD);
    SetPlayerSkillLevel(giveplayerid, WEAPONSKILL_SAWNOFF_SHOTGUN, 998);
    SetPlayerSkillLevel(giveplayerid, WEAPONSKILL_PISTOL, 998);
    SetPlayerSkillLevel(giveplayerid, WEAPONSKILL_PISTOL_SILENCED, 999);
    SetPlayerSkillLevel(giveplayerid, WEAPONSKILL_DESERT_EAGLE, 999);
    SetPlayerSkillLevel(giveplayerid, WEAPONSKILL_SHOTGUN, 999);
    SetPlayerSkillLevel(giveplayerid, WEAPONSKILL_SPAS12_SHOTGUN, 999);
    SetPlayerSkillLevel(giveplayerid, WEAPONSKILL_MICRO_UZI, 999);
    SetPlayerSkillLevel(giveplayerid, WEAPONSKILL_MP5, 999);
    SetPlayerSkillLevel(giveplayerid, WEAPONSKILL_AK47, 999);
    SetPlayerSkillLevel(giveplayerid, WEAPONSKILL_M4, 999);
    SetPlayerSkillLevel(giveplayerid, WEAPONSKILL_SNIPERRIFLE, 999);
    DeathTimer[giveplayerid] = 0;
    PlayerDead[giveplayerid] = 0;
    SetPlayerHealth(giveplayerid, 100);
    TextDrawHideForPlayer(giveplayerid,BFText);
    KnockedOut[giveplayerid] = 0;
    ApplyAnimation(giveplayerid, "CARRY", "crry_prtial", 4.0, 0, 0, 0, 0, 0);
    ClearAnimations(giveplayerid);
    UpdateDynamic3DTextLabelText(DeathLabel[giveplayerid], -1, " ");
    DestroyDynamic3DTextLabel(DeathLabel[giveplayerid]);
    TextDrawHideForPlayer(giveplayerid, DeadDraw[giveplayerid]);
    TogglePlayerControllable(giveplayerid, 1);
    return 1;
}
I added Update incase it didn't work..no avail.


Re: Text Label won't destroy/appears randomly on players. - Logic_ - 14.10.2016

Player Textdraws, labels are some stuff to be made in OnPlayerConnect and destroyed in OnPlayerDisconnect.


Re: Text Label won't destroy/appears randomly on players. - Dokins - 14.10.2016

It's a dynamic one, shouldn't be the case.


Re: Text Label won't destroy/appears randomly on players. - Logic_ - 14.10.2016

It is doesn't matter it's DYNAMIC or not.


Re: Text Label won't destroy/appears randomly on players. - GoldenLion - 14.10.2016

Yeah, like ALiScripter said, you need to destroy the labels when player disconnects if you haven't done it, otherwise they will appear on other players that will connect. This happens when you create double labels as well. I remember I had a bug like this in my server, I could keep killing injured players with a knife so it kept creating labels.


Re: Text Label won't destroy/appears randomly on players. - Logic_ - 14.10.2016

^^^
Make the label on OnPlayerConnect, update the label on OnPlayerSpawn, Update on OnPlayerDeath as well and Destroy on OnPlayerDisxonnect.


Re: Text Label won't destroy/appears randomly on players. - Dokins - 14.10.2016

Ahhh Thanks.