OnPlayerUpdate health -
ivndosos - 09.02.2018
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);
}
}
}
Re: OnPlayerUpdate health -
KayJ - 09.02.2018
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)
Re: OnPlayerUpdate health -
rfr - 09.02.2018
aren't you meant to make player variable instead of global ones?
and just change else if to if
Re: OnPlayerUpdate health -
David (Sabljak) - 09.02.2018
Gimme your color defines maybe it's on transparent.
Re: OnPlayerUpdate health -
wallen - 09.02.2018
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.
Re: OnPlayerUpdate health -
David (Sabljak) - 09.02.2018
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
Re: OnPlayerUpdate health -
Abagail - 09.02.2018
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.
Re: OnPlayerUpdate health -
Mugala - 09.02.2018
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)