17.09.2011, 13:01
So I have made a textdraw that shows the vehicle health, and it works.
I want it to have another color every time the vehicle's health reduces, and I've made this too.
But the textdraw is red all the time, while it should change colors as the health reduces.
I've defined the textdraw variable at the top of my script:
And this is my code:
Why?
I want it to have another color every time the vehicle's health reduces, and I've made this too.
But the textdraw is red all the time, while it should change colors as the health reduces.
I've defined the textdraw variable at the top of my script:
Код:
new Text:text_vehiclehealth;
Код:
public OnPlayerUpdate(playerid) { if(IsPlayerInAnyVehicle(playerid)==1) { new vehicle = GetPlayerVehicleID(playerid); new Float:vehiclehealth; GetVehicleHealth(vehicle,vehiclehealth); new string[128]; format(string,sizeof(string),"%0.0f",vehiclehealth); TextDrawDestroy(text_vehiclehealth); text_vehiclehealth = TextDrawCreate(5,433,string); TextDrawSetShadow(text_vehiclehealth,0); if(GetVehicleHealth(vehicle,vehiclehealth) <= 1000) TextDrawColor(text_vehiclehealth,0x00FF00FF); if(GetVehicleHealth(vehicle,vehiclehealth) <= 899) TextDrawColor(text_vehiclehealth,0x40FF00FF); if(GetVehicleHealth(vehicle,vehiclehealth) <= 799) TextDrawColor(text_vehiclehealth,0x80FF00FF); if(GetVehicleHealth(vehicle,vehiclehealth) <= 699) TextDrawColor(text_vehiclehealth,0xC0FF00FF); if(GetVehicleHealth(vehicle,vehiclehealth) <= 599) TextDrawColor(text_vehiclehealth,0xFFFF00FF); if(GetVehicleHealth(vehicle,vehiclehealth) <= 499) TextDrawColor(text_vehiclehealth,0xFFC000FF); if(GetVehicleHealth(vehicle,vehiclehealth) <= 399) TextDrawColor(text_vehiclehealth,0xFF8000FF); if(GetVehicleHealth(vehicle,vehiclehealth) <= 299) TextDrawColor(text_vehiclehealth,0xFF4000FF); if(GetVehicleHealth(vehicle,vehiclehealth) <= 249) TextDrawColor(text_vehiclehealth,0xFF0000FF); TextDrawShowForPlayer(playerid,text_vehiclehealth); } if(IsPlayerInAnyVehicle(playerid)==0) return TextDrawDestroy(text_vehiclehealth); return 1; }