SA-MP Forums Archive
Health colors - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Health colors (/showthread.php?tid=121439)



Health colors - westorz - 17.01.2010

Is it possible to make something like:
___________________________________________
player health is above 75% = Color Green I
player health is between 50%-75% = Color Yellow I
player health is between 25%-50% = Color Orange I
player health is under 25% = Color Red I
-------------------------------------------------I





Greetz Westorz


Re: Health colors - Miguel - 17.01.2010

pawn Код:
public OnGameModeInit()
{
  SetTimer("ChangeColor", 1000, true);
  return 1;
}
pawn Код:
forward ChangeColor();
public ChangeColor()
{
  for(new i = 0; i < MAX_PLAYERS; i ++)
  {
    new Float:health;
    GetPlayerHealth(i, health);
    if(health < 75)
    {
      if(health < 50)
      {
        if(health < 25) return SetPlayerColor(i, COLOR); // red
        else return SetPlayerColor(i, COLOR); // orange
      }
      else return SetPlayerColor(i, COLOR); // yellow
    }
    else return SetPlayerColor(i, COLOR); // green
  }
  return 1;
}