#define BULLET_HIT_PETROL_TANK 0
#define BULLET_HIT_LEFT_FRONT_WHEEL 1
#define BULLET_HIT_RIGHT_FRONT_WHEEL 2
#define BULLET_HIT_LEFT_BACK_WHEEL 3
#define BULLET_HIT_RIGHT_BACK_WHEEL 4
#define BULLET_HIT_BODY 5
//GetVehicleTireStatus
#define VEHICLE_RIGHT_BACK_WHEEL 0
#define VEHICLE_RIGHT_FRONT_WHEEL 1
#define VEHICLE_LEFT_BACK_WHEEL 2
#define VEHICLE_LEFT_FRONT_WHEEL 3
//Callbacks
forward OnPlayerShootVehiclePart(playerid, weaponid, vehicleid,hittype);
//Natives
native EnableVehicleDamage(true/false); //Add this under OnGamemodeInit/OnFilterscriptInit to enable/disable.
native EnableVehiclePetrolCapExplosion(true/false);//Add this under OnGamemodeInit/OnFilterscriptInit to enable/disable.
native EnableVehicleWheelTirePop(true/false);//Add this under OnGamemodeInit/OnFilterscriptInit to enable/disable.
native ToggleVehicleDamage();//Toggle Vehicle Damage
native ToggleVehiclePetrolCapExplosion();//Toggle Vehicle Petrol Cap Explosion
native ToggleVehicleWheelTirePop();//Toggle Vehicle Wheel Tire Pop
native GetVehicleTireStatus(Vehicleid,Tire);//Checking the Vehicle Tire Status (Return 1 : Tire Popped - Return 0 : Tire Unpopped)
public OnPlayerShootVehiclePart(playerid, weaponid, vehicleid,hittype)
{
if(hittype==BULLET_HIT_PETROL_TANK)//When player shoots on the petrol cap of a vehicle
{
new Float:vPosx,Float:vPosy,Float:vPosz;
GetVehiclePos(vehicleid, vPosx,vPosy,vPosz);
CreateExplosion(vPosx,vPosy,vPosz, 6, 30.0);
SetVehicleToRespawn(vehicleid);
SendClientMessage(playerid,-1,"You have hit the PETROL CAP!");
return 1;
}
if(hittype==BULLET_HIT_LEFT_FRONT_WHEEL)//When player shoots on the left front wheel of a vehicle
{
if(GetVehicleTireStatus(vehicleid,VEHICLE_LEFT_FRONT_WHEEL)==0)
{
SetVehicleTireStatus(vehicleid,VEHICLE_LEFT_FRONT_WHEEL);//will pop the left front wheel tire
SendClientMessage(playerid,-1,"You have hit the LEFT FRONT WHEEL!");
return 1;
}
else SendClientMessage(playerid,-1,"The LEFT FRONT WHEEL TIRE is already popped!");
}
if(hittype==BULLET_HIT_RIGHT_FRONT_WHEEL)//When player shoots on the right front wheel of a vehicle
{
if(GetVehicleTireStatus(vehicleid,VEHICLE_RIGHT_FRONT_WHEEL)==0)
{
SetVehicleTireStatus(vehicleid,VEHICLE_RIGHT_FRONT_WHEEL);//will pop the right front wheel tire
SendClientMessage(playerid,-1,"You have hit the RIGHT FRONT WHEEL!");
return 1;
}
else SendClientMessage(playerid,-1,"The RIGHT FRONT WHEEL TIRE is already popped!");
}
if(hittype==BULLET_HIT_LEFT_BACK_WHEEL)//When player shoots on the left back wheel of a vehicle
{
if(GetVehicleTireStatus(vehicleid,VEHICLE_LEFT_BACK_WHEEL)==0)
{
SetVehicleTireStatus(vehicleid,VEHICLE_LEFT_BACK_WHEEL);//will pop the left back wheel tire
SendClientMessage(playerid,-1,"You have hit the LEFT BACK WHEEL!");
return 1;
}
else SendClientMessage(playerid,-1,"The LEFT BACK WHEEL TIRE is already popped!");
}
if(hittype==BULLET_HIT_RIGHT_BACK_WHEEL)//When player shoots on the right back wheel of a vehicle
{
if(GetVehicleTireStatus(vehicleid,VEHICLE_RIGHT_BACK_WHEEL)==0)
{
SetVehicleTireStatus(vehicleid,VEHICLE_RIGHT_BACK_WHEEL);//will pop the right back wheel tire
SendClientMessage(playerid,-1,"You have hit the RIGHT BACK WHEEL!");
return 1;
}
else SendClientMessage(playerid,-1,"The RIGHT BACK WHEEL TIRE is already popped!");
}
if(hittype==BULLET_HIT_BODY)//When player shoots on a vehicle
{
SendClientMessage(playerid,-1,"You have hit the VEHICLE!");
return 1;
}
return 1;
}
2.1 - Added native ToggleVehicleDamage(); - Added native ToggleVehiclePetrolCapExplosion(); - Added native ToggleVehicleWheelTirePop(); - Added native GetVehicleTireStatus(Vehicleid,Tire); - Added new defines that can be used for GetVehiveTireStatus: #define VEHICLE_RIGHT_BACK_WHEEL #define VEHICLE_RIGHT_FRONT_WHEEL #define VEHICLE_LEFT_BACK_WHEEL #define VEHICLE_LEFT_FRONT_WHEEL - Changed native EnableVehicleDamage(toggle);//now with toggle (true/false) - Changed native EnableVehiclePetrolCapExplosion(toggle);//now with toggle (true/false) - Changed native EnableVehicleWheelTirePop(toggle);//now with toggle (true/false) - Fixed: Tires didnt popped good. 2.0 - Added EnableVehicleDamage(); - Added EnableVehiclePetrolCapExplosion(); - Added EnableVehicleWheelTirePop(); - Changed the define BULLET_HIT_VEHICLE to BULLET_HIT_BODY - Fixed the Petrol Caps offsets. The Petrol Caps is now accurate. 1.0 - First Release
- Improving Vehicle Parts offsets
- Adding bike support
- Adding middle wheels support (Thanks to king_hual for the suggestion)
- Adding more vehicle parts
Nice, You have done it, Hope to see you improving the offset as we tested it lately that on some vehicle it will take you 5-6 shot to blow a vehicle tank up.
|
You need to change the word "hitted" to "hit" there is no such word as "hitted" in the English language.
|
I've tested it on several cars and it doesn't seem to work, always showing me RIGHT FRONT WHEEL
|
2.0 - Added EnableVehicleDamage(); - Added EnableVehiclePetrolCapExplosion(); - Added EnableVehicleWheelTirePop(); - Changed the define BULLET_HIT_VEHICLE to BULLET_HIT_BODY - Fixed the Petrol Caps offsets. The Petrol Caps is now accurate.
Sorry to say but your calculations won't work on a 3d world properly
You need to do some angle calculations |