| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- #include <YSI_Coding\y_hooks>
- forward OnVehicleWrecked(vehicleid);
- static bool:Wrecked[MAX_VEHICLES];
- task OnVehicleUpdate[1500]()
- {
- foreach(new i : Vehicle)
- {
- new Float:health;
- GetVehicleHealth(i, health);
- if(health < 300 && Wrecked[i] == false)
- {
- OnVehicleWrecked(i);
- }
- }
- }
- public OnVehicleWrecked(vehicleid)
- {
- Wrecked[vehicleid] = true;
- SetVehicleHealth(vehicleid, 300);
- if(IsEngineVehicle(vehicleid))
- {
- new engine, lights, alarm, doors, bonnet, boot, objective;
- GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
- SetVehicleParamsEx(vehicleid, VEHICLE_PARAMS_OFF, lights, alarm, doors, bonnet, boot, objective);
- }
- foreach(new i : Player)
- {
- if(IsPlayerInVehicle(i, vehicleid) && GetPlayerVehicleSeat(i) == 0)
- {
- va_SendClientMessage(i, 0xFF6666FF, "> This vehicle (%s) is now badly damaged, the engine has stopped working.", GetVehicleName(vehicleid));
- break;
- }
- }
- return 1;
- }
- hook OnVehicleCreated(vehicleid)
- {
- Wrecked[vehicleid] = false;
- }
- hook OnVehicleSpawn(vehicleid)
- {
- Wrecked[vehicleid] = false;
- }
- hook OnPlayerShotVehicle(playerid, vehicleid, weaponid)
- {
- if(Wrecked[vehicleid] == false && IsEngineVehicle(vehicleid))
- {
- new Float:health;
- GetVehicleHealth(vehicleid, health);
- switch(weaponid)
- {
- case 0:
- {
- if(health > 310) SetVehicleHealth(vehicleid, health-10);
- else OnVehicleWrecked(vehicleid);
- }
- case 24, 25, 33, 34:
- {
- if(health > 420) SetVehicleHealth(vehicleid, health-120);
- else OnVehicleWrecked(vehicleid);
- }
- case 22, 23, 30, 31, 28, 29, 32:
- {
- if(health > 330) SetVehicleHealth(vehicleid, health-30);
- else OnVehicleWrecked(vehicleid);
- }
- }
- }
- }
- stock SetVehicleWrecked(vehicleid, bool:status)
- {
- Wrecked[vehicleid] = status;
- }
- stock IsVehicleWrecked(vehicleid)
- {
- if(Wrecked[vehicleid])
- {
- return true;
- }
- return false;
- }
|