XADRENALINEIX

My Vehicle Effector Pistol

Aug 7th, 2013
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.22 KB | None | 0 0
  1. #include <natives.h>
  2. #include <consts.h>
  3. #include <common.h>
  4. #include <types.h>
  5.  
  6. int ChangeWepType = 1;
  7. Vehicle foundcar;
  8. bool found;
  9. driver;
  10. lock;
  11.  
  12. void GetOffset(float distance, float *x, float *y, float *z){
  13.     Vector3 p;
  14.     GET_PED_BONE_POSITION(GetPlayerPed(), BONE_RIGHT_HAND, distance, distance * 0.042, distance * -0.113, &p);
  15.     *x = p.x;
  16.     *y = p.y;
  17.     *z = p.z;
  18. }
  19.  
  20. void Search(void){
  21.     if(found){
  22.         if(DOES_VEHICLE_EXIST(foundcar)){
  23.             if(IS_CHAR_SHOOTING(GetPlayerPed())){
  24.                 if(ChangeWepType==1)
  25.                     SET_PETROL_TANK_HEALTH(foundcar,-1);
  26.                 if(ChangeWepType==2)
  27.                     DELETE_CAR(&foundcar);
  28.                 if(ChangeWepType==3)
  29.                     APPLY_FORCE_TO_CAR(foundcar,true,0.0,0.0,1000.0,0.0,0.0,0.0,true,true,true,true);
  30.                 if(ChangeWepType==4){
  31.                     GET_DRIVER_OF_CAR(foundcar,&driver);
  32.                         if(DOES_CHAR_EXIST(driver))
  33.                             print("Driver's seat is currently occupied");
  34.                         else
  35.                         WARP_CHAR_INTO_CAR(GetPlayerPed(),foundcar);
  36.                     }
  37.                 if(ChangeWepType==5){
  38.                     GET_CAR_DOOR_LOCK_STATUS(foundcar,&lock);
  39.                         if(lock == VEHICLE_DOOR_UNLOCKED){
  40.                             LOCK_CAR_DOORS(foundcar,VEHICLE_DOOR_LOCKED_BOTH_SIDES);
  41.                             print("Doors locked!");
  42.                             }
  43.                        
  44.                         else{
  45.                             LOCK_CAR_DOORS(foundcar,VEHICLE_DOOR_UNLOCKED);
  46.                             print("Doors unlocked!");
  47.                     }
  48.                 }
  49.                 found = false;
  50.                 WAIT(500);
  51.             }
  52.             return;
  53.         }
  54.         else found = false;
  55.     }
  56.     else{
  57.         foundcar = INVALID_HANDLE;
  58.         float search, tx, ty, tz;
  59.         for (search = 1;search<100;search++){
  60.             found = false;
  61.             GetOffset(search, &tx, &ty, &tz);
  62.             foundcar = GET_CLOSEST_CAR(tx, ty, tz, 1.5f, 0, 71);
  63.             if (!DOES_VEHICLE_EXIST(foundcar)){
  64.                 foundcar = GET_CLOSEST_CAR(tx, ty, tz, 1.5f, 0, 69);
  65.                 if (!DOES_VEHICLE_EXIST(foundcar))
  66.                 foundcar = GET_CLOSEST_CAR(tx, ty, tz, 1.5f, 0, 70);
  67.             }
  68.             if (DOES_VEHICLE_EXIST(foundcar)){
  69.                 found = true;
  70.                 break;
  71.             }
  72.         }
  73.         return;
  74.     }
  75. }
  76.  
  77. void Searchinit(void){
  78.     uint Weapon;
  79.     GET_CURRENT_CHAR_WEAPON(GetPlayerPed(), &Weapon);
  80.     if (Weapon != WEAPON_PISTOL) {
  81.         found = false;
  82.         DISABLE_PLAYER_LOCKON(GET_PLAYER_ID(), false);
  83.         return;
  84.     }
  85.     if (IS_CHAR_IN_ANY_CAR(GetPlayerPed())){
  86.         found = false;
  87.         return;
  88.     }
  89.     DISABLE_PLAYER_LOCKON(GET_PLAYER_ID(), true);
  90.     if(IS_BUTTON_JUST_PRESSED(0,BUTTON_LB)){
  91.         if(ChangeWepType == 5) ChangeWepType = 1;
  92.         else ChangeWepType++;
  93.         if(ChangeWepType == 1) print("Destroy Vehicle");
  94.         if(ChangeWepType == 2) print("Delete Vehicle");
  95.         if(ChangeWepType == 3) print("Slingshot Vehicle");
  96.         if(ChangeWepType == 4) print("Teleport into Vehicle");
  97.         if(ChangeWepType == 5) print("Lock/Unlock Doors");
  98.     }
  99.     if (IS_BUTTON_PRESSED(0,BUTTON_LT))Search();
  100.     else found = false;
  101. }
  102.  
  103. void main(void){
  104.     THIS_SCRIPT_IS_SAFE_FOR_NETWORK_GAME();
  105.     print("Aim at a vehicle and fire to destroy it ~PAD_LT~ + ~PAD_RT~");
  106.     WAIT(2500);
  107.     print("Press ~PAD_LB~ to change fire option");
  108.     WAIT(2500);
  109.     print("Currently only for ped car's; I may edit to work for online player's vehicles");
  110.     WAIT(2500);
  111.     print("Destroy Vehicle");
  112.     WAIT(2500);
  113.     printlong("Created By X ADRENALINE IX");
  114.     if (!HAS_CHAR_GOT_WEAPON(GetPlayerPed(), WEAPON_PISTOL))
  115.         GIVE_WEAPON_TO_CHAR(GetPlayerPed(), WEAPON_PISTOL, AMMO_MAX, 0);
  116.     while(true)
  117.     {
  118.         Searchinit();
  119.         WAIT(0);
  120.     }
  121. }
Advertisement
Add Comment
Please, Sign In to add comment