Okay I just moved the code to OnPlayerDamage, however
What I'm trying to accomplish here is set player color by his hp by value, but the color doesn't change.
maybe I've done something wrong?
Код:
public OnPlayerDamage(&playerid, &Float:amount, &issuerid, &weapon, &bodypart)
{
new str[150],target, name1[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME];
GetPlayerName(playerid, name2,sizeof(name2));
GetPlayerName(target, name1,sizeof(name1));
if(issuerid != INVALID_PLAYER_ID && weapon == 34 && bodypart == 9)
{
format(str, sizeof(str), "{c3c33}* %s has just landed a {FFFFFF}head-shot {BCA9F5}on %s's head !", name1, name2);
SendClientMessageToAll(-1,str);
SendClientMessage(target, -1, "{BCA9F5}* You got +2 points for headshot");
GameTextForPlayer(target,"~y~+2", 300,4);
pInfo[playerid][Points] += 2;
}
new Float:phealth;
GetPlayerHealth(playerid);
if(phealth > 100)
{
SetPlayerColor(playerid, COLOR_GREEN);
}
if(phealth > 65)
{
SetPlayerColor(playerid, COLOR_YELLOW);
}
if(phealth > 50)
{
SetPlayerColor(playerid, COLOR_ORANGE);
}
if(phealth > 40)
{
SetPlayerColor(playerid, COLOR_RED);
}
new string[50], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
new Float:health;
GetPlayerHealth(playerid, health);
if(playerid != INVALID_PLAYER_ID && issuerid != INVALID_PLAYER_ID)
{
SetTimerEx("Damage", 4000, false, "i", issuerid);
format(string, sizeof(string), "{7FFFD4}%.0f damage by %s\n{7FFFD4}%.0f HP left", amount, name, health);
SetPlayerChatBubble(playerid, string, -1, 60.0, 3000);
}
return 1;
}