Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*************************************
- **************************************
- ******* Vehicle Damage Enabler *******
- *******[Alpha v2.1] by Salvator ******
- **************************************
- **************************************/
- //Credits and thanks
- //==================
- //AmigaBlizzard for showing me IsAirModel function
- //Gammix's vehicleplus.inc helped me with defining wheels position.
- //Abagail for improved IsDriverAvalable call and player loop.
- #include <a_samp>
- public OnFilterScriptInit()
- {
- print("Vehicle Damage Enabler [Alpha v2.1] by Salvator");
- return 1;
- }
- new AirDamage[] =
- {
- 0, // 0
- 0, // 1
- 0, // 2
- 0, // 3
- 0, // 4
- 0, // 5
- 0, // 6
- 0, // 7
- 0, // 8
- 0, // 9
- 0, // 10
- 0, // 11
- 0, // 12
- 0, // 13
- 0, // 14
- 0, // 15
- 0, // 16
- 0, // 17
- 0, // 18
- 0, // 19
- 0, // 20
- 0, // 21
- 10, // 22
- 16, // 23
- 56, // 24
- 60, // 25
- 60, // 26
- 48, // 27
- 8, // 28
- 10, // 29
- 12, // 30
- 12, // 31
- 8, // 32
- 30, // 33
- 50, // 34
- 0, // 35
- 0, // 36
- 0, // 37
- 56, // 38
- 0, // 39
- };
- new VehDamage[] =
- {
- 0, // 0
- 0, // 1
- 0, // 2
- 0, // 3
- 0, // 4
- 0, // 5
- 0, // 6
- 0, // 7
- 0, // 8
- 0, // 9
- 0, // 10
- 0, // 11
- 0, // 12
- 0, // 13
- 0, // 14
- 0, // 15
- 0, // 16
- 0, // 17
- 0, // 18
- 0, // 19
- 0, // 20
- 0, // 21
- 25, // 22
- 40, // 23
- 140, // 24
- 150, // 25
- 150, // 26
- 120, // 27
- 20, // 28
- 25, // 29
- 30, // 30
- 30, // 31
- 20, // 32
- 75, // 33
- 125, // 34
- 0, // 35
- 0, // 36
- 0, // 37
- 140, // 38
- 0, // 39
- };
- new
- vehicleDriver[MAX_VEHICLES] = INVALID_PLAYER_ID,
- playerCurVeh[MAX_PLAYERS] = INVALID_VEHICLE_ID;
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- if(newstate == PLAYER_STATE_DRIVER)
- {
- if(GetPlayerVehicleID(playerid) != INVALID_VEHICLE_ID)
- {
- vehicleDriver[GetPlayerVehicleID(playerid)] = playerid;
- playerCurVeh[playerid] = GetPlayerVehicleID(playerid);
- }
- }
- else if(oldstate == PLAYER_STATE_DRIVER)
- {
- if(playerCurVeh[playerid] != INVALID_VEHICLE_ID)
- {
- if(vehicleDriver[playerCurVeh[playerid]] == playerid) vehicleDriver[playerCurVeh[playerid]] = INVALID_PLAYER_ID;
- playerCurVeh[playerid] = INVALID_VEHICLE_ID;
- }
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason) {
- if(playerCurVeh[playerid] != INVALID_PLAYER_ID)
- if(vehicleDriver[playerCurVeh[playerid]] == playerid) vehicleDriver[playerCurVeh[playerid]] = INVALID_PLAYER_ID;
- return 1;
- }
- IsDriverAvailable(vehicleid)
- {
- return (vehicleDriver[vehicleid] != INVALID_PLAYER_ID) ? (false) : (true);
- }
- IsAirModel(modelid)
- {
- switch(modelid)
- {
- case 460, 476, 511, 512, 513, 519, 520, 553, 577, 592, 593, 417, 425, 447, 469, 487, 488, 497, 548, 563:
- return 1;
- }
- return 0;
- }
- public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
- {
- new wID = weaponid;
- new Float:vHealth; GetVehicleHealth(hitid, vHealth);
- if(hittype == 2 && !IsDriverAvailable(hitid) && vHealth > 249)
- {
- if(IsAirModel(GetVehicleModel(hitid)) == 1)
- {
- switch(wID)
- {
- case 22, 29: SetVehicleHealth(hitid, vHealth - AirDamage[wID]);
- case 23: SetVehicleHealth(hitid, vHealth - AirDamage[wID]);
- case 24, 38: SetVehicleHealth(hitid, vHealth - AirDamage[wID]);
- case 25, 26: SetVehicleHealth(hitid, vHealth - AirDamage[wID]);
- case 27: SetVehicleHealth(hitid, vHealth - AirDamage[wID]);
- case 28, 32: SetVehicleHealth(hitid, vHealth - AirDamage[wID]);
- case 30, 31: SetVehicleHealth(hitid, vHealth - AirDamage[wID]);
- case 33: SetVehicleHealth(hitid, vHealth - AirDamage[wID]);
- case 34: SetVehicleHealth(hitid, vHealth - AirDamage[wID]);
- }
- }
- else
- {
- switch(wID)
- {
- case 22, 29: SetVehicleHealth(hitid, vHealth - VehDamage[wID]);
- case 23: SetVehicleHealth(hitid, vHealth - VehDamage[wID]);
- case 24, 38: SetVehicleHealth(hitid, vHealth - VehDamage[wID]);
- case 25, 26: SetVehicleHealth(hitid, vHealth - VehDamage[wID]);
- case 27: SetVehicleHealth(hitid, vHealth - VehDamage[wID]);
- case 28, 32: SetVehicleHealth(hitid, vHealth - VehDamage[wID]);
- case 30, 31: SetVehicleHealth(hitid, vHealth - VehDamage[wID]);
- case 33: SetVehicleHealth(hitid, vHealth - VehDamage[wID]);
- case 34: SetVehicleHealth(hitid, vHealth - VehDamage[wID]);
- }
- }
- new vModel = GetVehicleModel(hitid);
- new Float:hX, Float:hY, Float:hZ, Float:rX, Float:rY, Float:rZ;
- GetVehicleModelInfo(vModel, VEHICLE_MODEL_INFO_WHEELSFRONT, hX, hY, hZ);
- GetVehicleModelInfo(vModel, VEHICLE_MODEL_INFO_WHEELSREAR, rX, rY, rZ);
- new panels, doors, lights, tires;
- //Left front wheel
- if( fX >= hX - 3.0 && fX <= hX + 0.0 &&
- fY >= hY - 0.5 && fY <= hY + 0.5 &&
- fZ >= hZ - 0.5 && fZ <= hZ + 0.5 )
- {
- GetVehicleDamageStatus(hitid, panels, doors, lights, tires);
- UpdateVehicleDamageStatus(hitid, panels, doors, lights,(tires | 0b1000));
- }
- //Right front wheel
- if( fX >= hX - 0.5 && fX <= hX + 0.5 &&
- fY >= hY - 0.5 && fY <= hY + 0.5 &&
- fZ >= hZ - 0.5 && fZ <= hZ + 0.5 )
- {
- GetVehicleDamageStatus(hitid, panels, doors, lights, tires);
- UpdateVehicleDamageStatus(hitid, panels, doors, lights, (tires | 0b0010));
- }
- //Left rear wheel
- if( fX >= rX - 3.0 && fX <= rX + 0.0 &&
- fY >= rY - 0.5 && fY <= rY + 0.5 &&
- fZ >= rZ - 0.5 && fZ <= rZ + 0.5 )
- {
- GetVehicleDamageStatus(hitid, panels, doors, lights, tires);
- UpdateVehicleDamageStatus(hitid, panels, doors, lights, (tires | 0b0100));
- }
- //Right rear wheel
- if( fX >= rX - 0.5 && fX <= rX + 0.5 &&
- fY >= rY - 0.5 && fY <= rY + 0.5 &&
- fZ >= rZ - 0.5 && fZ <= rZ + 0.5 )
- {
- GetVehicleDamageStatus(hitid, panels, doors, lights, tires);
- UpdateVehicleDamageStatus(hitid, panels, doors, lights, (tires | 0b0001));
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement