SA-MP Forums Archive
Help with Damage Text Label. [rep] - 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: Help with Damage Text Label. [rep] (/showthread.php?tid=615969)



Help with Damage Text Label. [rep] - Farzam - 29.08.2016

As the title says.

The code is applying and doing the functions late, or it doesn't even do it.
When it does, It removes it fast.

Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
	new gString[128];
	format(gString, sizeof gString, "{ff0000}-%.0f",amount);
	Delete3DTextLabel(PlayerDamage[playerid]);
    PlayerDamage[playerid] = Create3DTextLabel(gString, 0xFFFFFFFF, 0.0, 0.0, 0.0, 7.5, -1);
    Attach3DTextLabelToPlayer(PlayerDamage[playerid], playerid, 0.0, 0.0, 0.4);
    SetTimerEx("RemoveDamageLabel", 3000, false, "d", _:PlayerDamage[playerid]);
    return 1;
}
forward RemoveDamageLabel(Text3D:labelid);
public RemoveDamageLabel(Text3D:labelid)
{
    return Delete3DTextLabel(labelid);
}



Re: Help with Damage Text Label. [rep] - Shinja - 29.08.2016

PHP код:
public OnPlayerTakeDamage(playeridissueridFloat:amountweaponidbodypart)
{
    new 
gString[128];
    
format(gStringsizeof gString"{ff0000}-%.0f",amount);
    
Delete3DTextLabel(PlayerDamage[playerid]);
    
PlayerDamage[playerid] = Create3DTextLabel(gString0xFFFFFFFF0.00.00.07.5, -1);
    
Attach3DTextLabelToPlayer(PlayerDamage[playerid], playerid0.00.00.4);
    
SetTimerEx("RemoveDamageLabel"3000false"d"playerid);
    return 
1;
}
forward RemoveDamageLabel(playerid);
public 
RemoveDamageLabel(playerid)
{
    
Delete3DTextLabel(PlayerDamage[playerid]);




Re: Help with Damage Text Label. [rep] - jlalt - 29.08.2016

You have to save players timer id and kill it if they got a damage before the callback of remove get called

PHP код:
new PDamageTimer[MAX_PLAYERS];
public 
OnPlayerTakeDamage(playeridissueridFloat:amountweaponidbodypart)
{
    new 
gString[128];
    
format(gStringsizeof gString"{ff0000}-%.0f",amount);
    if(
_:PlayerDamage[playerid] != -1)
    {
        
Delete3DTextLabel(PlayerDamage[playerid]);
        
PlayerDamage[playerid] = Text3D:-1;
        
KillTimer(PDamageTimer[playerid]);
    }
    
PlayerDamage[playerid] = Create3DTextLabel(gString0xFFFFFFFF0.00.00.07.5, -1);
    
Attach3DTextLabelToPlayer(PlayerDamage[playerid], playerid0.00.00.4);
    
PDamageTimer[playerid] = SetTimerEx("RemoveDamageLabel"3000false"d"playerid);
    return 
1;
}
forward RemoveDamageLabel(playerid);
public 
RemoveDamageLabel(playerid)
{
    
Delete3DTextLabel(PlayerDamage[playerid]);
    
PlayerDamage[playerid] = Text3D:-1;
    return 
1;

also be sure to do that on player connect
PHP код:
PlayerDamage[playerid] = Text3D:-1



Re: Help with Damage Text Label. [rep] - Farzam - 29.08.2016

Thanks for the help.
+rep for you