24.01.2010, 00:00
pawn Code:
/* not tested, but it should work*/
forward myTimer();
forward OnVehicleHealthChange(vehicleid, newhealth, oldhealth);
new
oldVehicleHealth[MAX_VEHICLES], newVehicleHealth[MAX_VEHICLES]; // change MAX_VEHICLES to your own vehicle amount.
Float:VehicleHealth(vehicleid)
{
new
Float:health;
GetVehicleHealth(vehicleid, health);
return health;
}
public myTimer()
{
for(new v = 1; v <= MAX_VEHICLES; v++) // change MAX_VEHICLES to your own vehicle amount or use foreach function.
{
newVehicleHealth[v] = floatround(VehicleHealth(v));
if(newVehicleHealth[v] != oldVehicleHealth[v])
{
OnVehicleHealthChange(v, newVehicleHealth[v], oldVehicleHealth[v]);
oldVehicleHealth[v] = newVehicleHealth[v];
}
}
return true;
}
public OnVehicleHealthChange(vehicleid, newhealth, oldhealth)
{
if(newhealth < oldhealth)
{
// damage..
}
return true;
}
// under OnGameModeInit/OnFilterScriptInit-callback.
SetTimer("myTimer", 1000, true); // every second.