How to stop vehicles from blowing up?
#7

I remembered that you can't hook functions using y_hooks and I couldn't figure out how to do it with ALS. Here's the new code, I added a game text and made the timer call every 3 seconds, instead of every 1.5. 3 seconds is still more than enough time. Also note that the OnVehicleSpawn callback only gets called when a vehicle respawns. When I figure out the function hooking, I'll try to hook CreateVehicle to add the health check timer for you!

pawn Код:
new
    Timer:healthCheckTimer[MAX_VEHICLES]
;

hook OnVehicleSpawn(vehicleid)
{
    healthCheckTimer[vehicleid] = repeat checkVehicleHealth(vehicleid);
    return 1;
}

hook OnVehicleDeath(vehicleid)
{
    stop healthCheckTimer[vehicleid];
    return 1;
}

timer checkVehicleHealth[3000](vehicleid)
{
    new
        Float:vehicleHealth
    ;
   
    GetVehicleHealth(vehicleid, vehicleHealth);
    if(vehicleHealth < 400.0)
    {
        foreach(new i : Player)
            if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
                if(GetPlayerVehicleID(i) == vehicleid) GameTextForPlayer(i, "~w~You broke the vehicle, ~r~idiot~w~!", 3000, 3);
       
        SetVehicleHealth(vehicleid, 400.0);
       
        new engine, lights, alarm, doors, bonnet, boot, objective;
        GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
        SetVehicleParamsEx(vehicleid, 0, lights, alarm, doors, bonnet, boot, objective);
    }
    return 1;
}
Reply


Messages In This Thread
How to stop vehicles from blowing up? - by Yves - 19.03.2013, 12:46
Respuesta: How to stop vehicles from blowing up? - by Xabi - 19.03.2013, 12:50
Re: How to stop vehicles from blowing up? - by Private200 - 19.03.2013, 12:51
Re: How to stop vehicles from blowing up? - by Konstantinos - 19.03.2013, 12:52
Re: How to stop vehicles from blowing up? - by Scenario - 19.03.2013, 12:57
Re: How to stop vehicles from blowing up? - by Yves - 19.03.2013, 13:04
Re: How to stop vehicles from blowing up? - by Scenario - 19.03.2013, 13:35
Re: How to stop vehicles from blowing up? - by Yves - 19.03.2013, 13:45
Re: How to stop vehicles from blowing up? - by Scenario - 19.03.2013, 14:00
Re: How to stop vehicles from blowing up? - by Yves - 19.03.2013, 14:09

Forum Jump:


Users browsing this thread: 6 Guest(s)