Try a different approach. Untested and unsure if it works. Basically, the reason it is flashing is because you're updating the textdraws on OnPlayerUpdate instead of OnPlayerTakeDamage.
pawn Код:
new PlayerText: HPP[MAX_PLAYERS]; //Or whatever the textdraw name is.
public OnGameModeInit (){
for(new i = 0; i < MAX_PLAYERS; i++){
//create the textdraws here
}
return 1;
}
forward UpdateHealthTD(playerid);
public UpdateHealthTD(playerid) {
if(connected[playerid] == false)
{
new Float:hptd;
GetPlayerHealth(playerid, hptd);
if(hptd >= 100)
{
PlayerTextDrawHide(playerid, HPP[playerid]);
PlayerTextDrawBackgroundColor(playerid,HPP[playerid], 16711935);
PlayerTextDrawFont(playerid,HPP[playerid], 3);
PlayerTextDrawLetterSize(playerid,HPP[playerid], 0.449999, 1.800000);
PlayerTextDrawSetOutline(playerid,HPP[playerid], 1);
PlayerTextDrawSetProportional(playerid,HPP[playerid], 1);
PlayerTextDrawShow(playerid, HPP[playerid]);
PlayerTextDrawColor(playerid, HPP[playerid], 255);
}
else if(hptd > 65)
{
PlayerTextDrawHide(playerid, HPP[playerid]);
PlayerTextDrawBackgroundColor(playerid,HPP[playerid], -65281);
PlayerTextDrawFont(playerid,HPP[playerid], 3);
PlayerTextDrawLetterSize(playerid,HPP[playerid], 0.449999, 1.800000);
PlayerTextDrawSetOutline(playerid,HPP[playerid], 1);
PlayerTextDrawSetProportional(playerid,HPP[playerid], 1);
PlayerTextDrawShow(playerid, HPP[playerid]);
PlayerTextDrawColor(playerid, HPP[playerid], 255);
}
else if(hptd > 50)
{
PlayerTextDrawHide(playerid, HPP[playerid]);
PlayerTextDrawBackgroundColor(playerid,HPP[playerid], -5963521);
PlayerTextDrawFont(playerid,HPP[playerid], 3);
PlayerTextDrawLetterSize(playerid,HPP[playerid], 0.449999, 1.800000);
PlayerTextDrawSetOutline(playerid,HPP[playerid], 1);
PlayerTextDrawSetProportional(playerid,HPP[playerid], 1);
PlayerTextDrawShow(playerid, HPP[playerid]);
PlayerTextDrawColor(playerid, HPP[playerid], 255);
}
else if(hptd >= 1)
{
PlayerTextDrawHide(playerid, HPP[playerid]);
PlayerTextDrawBackgroundColor(playerid, HPP[playerid], -16776961);
PlayerTextDrawFont(playerid,HPP[playerid], 3);
PlayerTextDrawLetterSize(playerid,HPP[playerid], 0.449999, 1.800000);
PlayerTextDrawSetOutline(playerid,HPP[playerid], 1);
PlayerTextDrawSetProportional(playerid,HPP[playerid], 1);
PlayerTextDrawShow(playerid, HPP[playerid]);
PlayerTextDrawColor(playerid, HPP[playerid], 255);
}
}
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart) {
UpdateHealthTD(playerid);
return 1;
}