OnPlayerUpdate health
#1

So it works but sometimes the red color won't apply on the player's name, all of the colors work till orange

Код:
public OnPlayerUpdate(playerid)
{
    // Health TD.
		    new InfoString[110];
			if(IsPlayerConnected(playerid))
	{
		if(IsPlayerNPC(playerid)) return 0;
		new Float:healthplayer;
		GetPlayerHealth(playerid, healthplayer);
		format(InfoString, sizeof(InfoString), "hp: %.0f", healthplayer);
		TextDrawSetString(HPP[playerid], InfoString);
 		format(InfoString, sizeof(InfoString), "%d", pInfo[playerid][Points]);
		TextDrawSetString(CASH4[playerid], InfoString);
	    if(healthplayer >= 100)
	    {
	      SetPlayerColor(playerid, COLOR_LIME);
	    }
	    else if(healthplayer > 65)
	    {
	      SetPlayerColor(playerid, COLOR_YELLOW);
	    }
	    else if(healthplayer > 50)
	    {
	      SetPlayerColor(playerid, COLOR_ORANGE);
	    }
	    else if(healthplayer > 40)
	    {
	      SetPlayerColor(playerid, COLOR_RED);
	    }
	}
}
Reply
#2

Did you check your red color code? If not then check it, still not working? Use Hex code instead of COLOR_RED but of different(other than one you defined it)
Reply
#3

aren't you meant to make player variable instead of global ones?

and just change else if to if
Reply
#4

Gimme your color defines maybe it's on transparent.
Reply
#5

PHP код:
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_ORANGE 0xFF9900AA
#define COLOR_RED 0xAA3333AA
#define COLOR_LIME 0x10F441AA 
PS: I'm working on this gamemode with him so yeah, these are the colours defines.
Reply
#6

Quote:
Originally Posted by wallen
Посмотреть сообщение
PHP код:
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_ORANGE 0xFF9900AA
#define COLOR_RED 0xAA3333AA
#define COLOR_LIME 0x10F441AA 
PS: I'm working on this gamemode with him so yeah, these are the colours defines.
When its AA on the end that makes transparent color. Put FF.

PHP код:
#define COLOR_YELLOW 0xFFFF00FF
#define COLOR_ORANGE 0xFF9900FF
#define COLOR_RED 0xAA3333FF
#define COLOR_LIME 0x10F441FF 
That can make problems... try
Reply
#7

Whatever "pPoints" does, I'm sure it doesn't update on its own. You set it through the script, so you only need to update it when you change its value.

For health, the same goes. You can just use OnPlayerTakeDamage, it's called every time the player takes damage, even if self inflicted (e.g: fall damage). Update the textdraw/player color there.
Reply
#8

define color red from 1, instead of 40.
when player takes damage from 50 to 39, red will not appear, orange will stay.
so use else if(healthplayer >= 1) isntead of else if(healthplayer > 40)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)