SA-MP Forums Archive
[Include] [0.3z]a_OnPlayerShootVehiclePart - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] [0.3z]a_OnPlayerShootVehiclePart (/showthread.php?tid=488920)

Pages: 1 2


[0.3z]a_OnPlayerShootVehiclePart - Admigo - 19.01.2014

Hello.

Since i saw the great features of the new sa-mp 0.3z RC update i was thinking about detecting wheels and the petrol cap from all vehicles.
Whats new?
This include will add a new callback and new natives:
pawn Code:
#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)
How to use?
1. Download the a_vshot.zip and extract it in the sa-mp folder.
2. Add #include <a_vshot.inc> on the top of your script
3. Add public OnPlayerShootVehiclePart(playerid, weaponid, vehicleid,hittype) in your script.

Example
This is an example how you can use this callback.
Example 1
pawn Code:
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;
}
Videos
http://www.youtube.com/watch?v=65I1y8hbWbk

Changelog
Code:
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
Future Updates
pawn Code:
- Improving Vehicle Parts offsets
- Adding bike support
- Adding middle wheels support (Thanks to king_hual for the suggestion)
- Adding more vehicle parts
Downloads

Version 2.1 (Latest)
https://dl.dropboxusercontent.com/u/...vshot_v2.1.zip
http://pastebin.com/6nUTazQR

Version 2.0
https://dl.dropboxusercontent.com/u/...a_vshot_v2.zip
http://pastebin.com/bJpdge4T

Version 1.0
https://dl.dropboxusercontent.com/u/...98/a_vshot.zip
http://pastebin.com/Sf3ybSUt

Notice
- Not all vehicles have the right offset for the vehicle parts (Wheels only). I will improve the offsets later.
- Explosive and Melee weapons will not do any damage to the vehicles.

Credits
- Admigo(Scripting)
- pds2k12(Fixed the callbacks hooks)


Respuesta: [0.3z]a_OnPlayerShootVehiclePart - Swedky - 19.01.2014

Woooooow, nice!

+Rep .


PS: Pastebin? .


Re: [0.3z]a_OnPlayerShootVehiclePart - Patrick - 19.01.2014

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.


Re: [0.3z]a_OnPlayerShootVehiclePart - Admigo - 19.01.2014

Quote:
Originally Posted by EnzoMetlc
View Post
Woooooow, nice!

+Rep .


PS: Pastebin? .
Thanks, pastebin added
Quote:
Originally Posted by pds2k12
View Post
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.
Thanks, Yes i will improve the offsets later:P


Re: [0.3z]a_OnPlayerShootVehiclePart - KingHual - 19.01.2014

Good job!


Re: [0.3z]a_OnPlayerShootVehiclePart - Pottus - 19.01.2014

You need to change the word "hitted" to "hit" there is no such word as "hitted" in the English language.


Re: [0.3z]a_OnPlayerShootVehiclePart - Admigo - 19.01.2014

Quote:
Originally Posted by [uL]Pottus
View Post
You need to change the word "hitted" to "hit" there is no such word as "hitted" in the English language.
Sorry, i am not perfect.
Changed.


Re: [0.3z]a_OnPlayerShootVehiclePart - Akcent_Voltaj - 20.01.2014

cool Repped!!!!


Re: [0.3z]a_OnPlayerShootVehiclePart - iZN - 20.01.2014

Nice work Admigo.


Re: [0.3z]a_OnPlayerShootVehiclePart - Lordzy - 20.01.2014

Nice work!


Re: [0.3z]a_OnPlayerShootVehiclePart - PaulDinam - 20.01.2014

I've tested it on several cars and it doesn't seem to work, always showing me RIGHT FRONT WHEEL


Re: [0.3z]a_OnPlayerShootVehiclePart - Admigo - 20.01.2014

Quote:
Originally Posted by PaulDinam
Посмотреть сообщение
I've tested it on several cars and it doesn't seem to work, always showing me RIGHT FRONT WHEEL
Show me your code?


Re: [0.3z]a_OnPlayerShootVehiclePart - Kar - 21.01.2014

Sorry to say but your calculations won't work on a 3d world properly

You need to do some angle calculations


Re: [0.3z]a_OnPlayerShootVehiclePart - Admigo - 21.01.2014

Updated the include to version 2.0.
Код:
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.
Quote:
Originally Posted by Kar
Посмотреть сообщение
Sorry to say but your calculations won't work on a 3d world properly

You need to do some angle calculations
Did you even tested the include? Version 2.0 will fix the petrol cap offsets.
Other offsets will be done later.


Re: [0.3z]a_OnPlayerShootVehiclePart - PaulDinam - 21.01.2014

Still doesn't work well


Re: [0.3z]a_OnPlayerShootVehiclePart - Ace155 - 21.01.2014

Very cool. +rep


Re: [0.3z]a_OnPlayerShootVehiclePart - Admigo - 21.01.2014

Quote:
Originally Posted by PaulDinam
Посмотреть сообщение
Still doesn't work well
If you dont show me your code, how i am able to help you?


Re: [0.3z]a_OnPlayerShootVehiclePart - Diesel5 - 21.01.2014

Great work!


Re: [0.3z]a_OnPlayerShootVehiclePart - Admigo - 21.01.2014

Quote:
Originally Posted by Diesel5
Посмотреть сообщение
Great work!
Thanks.
Suggestions for adding more vehicle parts are welcome.
What vehicle part you wat to see detectable?


Re: [0.3z]a_OnPlayerShootVehiclePart - PT - 21.01.2014

Nice Work.

add some way do destroy engine ( good to RP )