i tried that and it didn`t work.
Here is my code.
PHP код:
#include <a_samp>
#include <zcmd>
new Text:HealthText[MAX_PLAYERS];
new HealthTimer[MAX_PLAYERS];
public OnFilterScriptInit()
{
printf("Health System");
return 1;
}
public OnPlayerConnect(playerid)
{
HealthText[playerid] = TextDrawCreate(450.0, 375.0," ");
TextDrawHideForPlayer(playerid,HealthText[playerid]);
TextDrawAlignment(HealthText[playerid],0);
TextDrawSetProportional(HealthText[playerid],1);
TextDrawSetShadow(HealthText[playerid], 1);
TextDrawSetOutline(HealthText[playerid], 2);
TextDrawLetterSize(HealthText[playerid],0.60,2.0);
TextDrawFont(HealthText[playerid], 3);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
TextDrawDestroy(HealthText[playerid]);
return 1;
}
public OnPlayerStateChange(playerid,newstate,oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
HealthTimer[playerid] = SetTimerEx("HealthDown", 1000, true, "i", playerid); // Healthdown timer
TextDrawShowForPlayer(playerid, HealthText[playerid]);
}
else
{
TextDrawHideForPlayer(playerid,HealthText[playerid]);
TextDrawSetString(HealthText[playerid], " ");
}
return 1;
}
forward HealthDown(playerid);
forward upper(str[]);
public HealthDown(playerid)
{
new string[128];
if(IsPlayerInAnyVehicle(playerid))
{
new Float:health;
new veh = GetPlayerVehicleID(playerid);
GetVehicleHealth(veh, health);
if(health == 1000) format(string,sizeof(string)," Health: IIIIIIIIII");
else if(health >= 900) format(string,sizeof(string),"~g~ Health: ~g~IIIIIIIII");
else if(health >= 800) format(string,sizeof(string),"~g~ Health: ~g~IIIIIIII");
else if(health >= 700) format(string,sizeof(string),"~g~ Health: ~y~IIIIIII");
else if(health >= 600) format(string,sizeof(string),"~g~ Health: ~y~IIIIII");
else if(health >= 500) format(string,sizeof(string),"~g~ Health: ~y~IIIII");
else if(health >= 400) format(string,sizeof(string),"~g~ Health: ~y~IIII");
else if(health >= 300) format(string,sizeof(string),"~g~ Health: ~r~III");
else if(health >= 200) format(string,sizeof(string),"~g~ Health: ~r~II");
else if(health >= 100) format(string,sizeof(string),"~g~ Health: ~r~I");
upper(string);
TextDrawSetString(HealthText[playerid], string);
}
else
{
format(string,sizeof(string),"~g~ Health: ~w~ ");
KillTimer(HealthTimer[playerid]);
}
}
public upper(str[])
{
for(new i = 0, n = strlen(str); i <n; i ++)
{
str[i] = toupper(str[i]);
}
return 1;
}
IIIIIIIIII is still iiiiiiiiii in game. Why?