#1

I have my hp td, It's on onplayerupdate but sometimes it sortof flashes/fades, I cant really explain how

it dissapears and appears but like really really really quick, what causes it?
Reply
#2

I'd say that's lag if you weren't using any TextDrawHide/show repeatedly somewhere?
Reply
#3

Are you running the server on your own machine (localhost)?
Reply
#4

Yeah It's on local host.

Код:
public OnPlayerUpdate(playerid)
{
	    	// Health TD.
		    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);
			}
Reply
#5

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;
}
Reply
#6

I didn't want to use it onplayerdamage because this

https://sampforum.blast.hk/showthread.php?tid=649877
Reply
#7

It's always going to keep flashing if you use OnPlayerUpdate though, because OnPlayerUpdate is called ~30 times per second and you are hiding and showing the textdraws in that timespan, even if the health stays the same.

pawn Код:
if(hptd >= 100) //Imagine health is at 100 points.
    {
        PlayerTextDrawHide(playerid, HPP[playerid]); //Even if you don't lose any health, the textdraw is hidden.
        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]); //The textdraw is shown again even if the player didn't take any damage.
        PlayerTextDrawColor(playerid, HPP[playerid], 255);

    }
Reply
#8

Quote:
Originally Posted by GRiMMREAPER
Посмотреть сообщение
It's always going to keep flashing if you use OnPlayerUpdate though, because OnPlayerUpdate is called ~30 times per second and you are hiding and showing the textdraws in that timespan, even if the health stays the same.
do what he said or try to update with 1 sec timer and onplayertakedamage (it will decrease flash time)
Reply
#9

Quote:
Originally Posted by Mugala
Посмотреть сообщение
do what he said or try to update with 1 sec timer and onplayertakedamage (it will decrease flash time)
Why is the timer necessary? OnPlayerTakeDamage callback is called when a player takes damage, therefore a timer is redundant.
Reply
#10

Quote:
Originally Posted by GRiMMREAPER
Посмотреть сообщение
Why is the timer necessary? OnPlayerTakeDamage callback is called when a player takes damage, therefore a timer is redundant.
cuz when he uses SetPlayerHealth, OnPlayerTakeDamage isn't called.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)