13.10.2012, 15:17
Hey there!
I have a little problem. I created a timer that checks the car health, If it's below 250, it will restore it to exactly 250, so the car doesn't blow up (the code is below). I also want the car engine to stop when the health is below the limit, so the player would be forced to somehow, repair the car, or change it. How can I do that in my code?
I have a little problem. I created a timer that checks the car health, If it's below 250, it will restore it to exactly 250, so the car doesn't blow up (the code is below). I also want the car engine to stop when the health is below the limit, so the player would be forced to somehow, repair the car, or change it. How can I do that in my code?
Код:
public OnFilterScriptInit()
{
SetTimer("carhealthcheck",500,1);
return 1;
}
#else
main(){}
#endif
forward carhealthcheck();
public carhealthcheck()
{
new Float:vhp;
for(new vehicleid; vehicleid<MAX_VEHICLES;vehicleid++)
{
if(GetVehicleModel(vehicleid)==0)continue; //only returns 0 when vehicle is invalid (not spawned)
GetVehicleHealth(vehicleid,vhp);
if(vhp<250.0)SetVehicleHealth(vehicleid,250);
}
}

