Function/Callback that detects...
#4

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.
Reply


Messages In This Thread
Function/Callback that detects... - by Torran - 23.01.2010, 21:52
Re: Function/Callback that detects... - by mansonh - 23.01.2010, 22:21
Re: Function/Callback that detects... - by Torran - 23.01.2010, 22:27
Re: Function/Callback that detects... - by Correlli - 24.01.2010, 00:00
Re: Function/Callback that detects... - by Torran - 24.01.2010, 00:04
Re: Function/Callback that detects... - by Correlli - 24.01.2010, 00:06
Re: Function/Callback that detects... - by Torran - 24.01.2010, 00:15
Re: Function/Callback that detects... - by Correlli - 24.01.2010, 00:42
Re: Function/Callback that detects... - by Torran - 24.01.2010, 00:47
Re: Function/Callback that detects... - by Correlli - 24.01.2010, 00:48

Forum Jump:


Users browsing this thread: 2 Guest(s)