XADRENALINEIX

Nayjames123's Grab handle of car you're aiming at

Jun 4th, 2013
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.10 KB | None | 0 0
  1. #include <natives.h>
  2. #include <consts.h>
  3. #include <common.h>
  4. #include <types.h>
  5. #define wGun WEAPON_PISTOL
  6.  
  7. void Dostuff(Vehicle foundcar)
  8. {
  9.     float x, y, z;
  10.     GET_CAR_COORDINATES(foundcar, &x, &y, &z);
  11.     DRAW_LIGHT_WITH_RANGE(x, y, z, 0, 255, 0, 27.0f, 5.0f);
  12.     DRAW_COLOURED_CYLINDER(x, y, z+1, 1, 1, 0, 0, 255, 255);
  13. }
  14.  
  15. void GetOffset(float distance, float *x, float *y, float *z)
  16. {
  17.     Vector3 p;
  18.     GET_PED_BONE_POSITION(GetPlayerPed(), BONE_RIGHT_HAND, distance, distance * 0.042, distance * -0.113, &p);
  19.     *x = p.x;
  20.     *y = p.y;
  21.     *z = p.z;
  22. }
  23.  
  24. void Search(void)
  25. {
  26.     Vehicle Veh;
  27.     bool found = false;
  28.     float search, tx, ty, tz;
  29.     for (search = 1;search<100;search++)
  30.     {
  31.         found = false;
  32.         GetOffset(search, &tx, &ty, &tz);
  33.         Veh = GET_CLOSEST_CAR(tx, ty, tz, 1.5f, 0, 71);
  34.         if (!DOES_VEHICLE_EXIST(Veh))
  35.         {
  36.             Veh = GET_CLOSEST_CAR(tx, ty, tz, 1.5f, 0, 69);
  37.             if (!DOES_VEHICLE_EXIST(Veh))
  38.             Veh = GET_CLOSEST_CAR(tx, ty, tz, 1.5f, 0, 70);
  39.         }
  40.         if (DOES_VEHICLE_EXIST(Veh)){found = true; break;}
  41.     }
  42.     if (found)
  43.     {
  44.         Dostuff(Veh);
  45.     }
  46. }
  47.  
  48.  
  49. void Searchinit(void)
  50. {
  51.     if (!HAS_CHAR_GOT_WEAPON(GetPlayerPed(), wGun))
  52.         GIVE_WEAPON_TO_CHAR(GetPlayerPed(), wGun, AMMO_MAX, 0);
  53.     uint Weapon;
  54.     GET_CURRENT_CHAR_WEAPON(GetPlayerPed(), &Weapon);
  55.     if (Weapon != wGun) {DISABLE_PLAYER_LOCKON(GET_PLAYER_ID(), false); return;}
  56.     if (IS_CHAR_IN_ANY_CAR(GetPlayerPed())) return;
  57.     DISABLE_PLAYER_LOCKON(GET_PLAYER_ID(), true);
  58.     if (IS_BUTTON_PRESSED(0, BUTTON_L2))Search();
  59. }
  60.  
  61.  
  62. void main(void)
  63. {
  64.     THIS_SCRIPT_IS_SAFE_FOR_NETWORK_GAME();
  65.     while(true)
  66.     {
  67.         Searchinit();
  68.         WAIT(0);
  69.     }
  70. }  
  71.  
  72. /*** Example usage
  73. void Dostuff(Vehicle foundcar)
  74. {
  75.     if (IS_CHAR_SHOOTING(GetPlayerPed())
  76.     {
  77.         float px, py, pz, cx, cy, cz, fx, fy, fz, dist;
  78.         GET_CHAR_COORDINATES(GetPlayerPed(), &px, &py, &pz);
  79.         GET_CAR_COORDINATES(foundcar, &cx, &cy, &cz);
  80.         GET_DISTANCE_BETWEEN_COORDS_3D(px, py, pz, cx, cy, cz, &dist);
  81.         fx = (cx - px) / dist * 1000;
  82.         fy = (cy - py) / dist * 1000;
  83.         fz = (cz - pz) / dist * 1000;
  84.         APPLY_FORCE_TO_CAR(foundcar, true, fx, fy, fz, 0, 0, 0, true, false, true, true);
  85.     }
  86. }
  87. ***/
Advertisement
Add Comment
Please, Sign In to add comment