Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <natives.h>
- #include <consts.h>
- #include <common.h>
- #include <types.h>
- #define wGun WEAPON_PISTOL
- void Dostuff(Vehicle foundcar)
- {
- float x, y, z;
- GET_CAR_COORDINATES(foundcar, &x, &y, &z);
- DRAW_LIGHT_WITH_RANGE(x, y, z, 0, 255, 0, 27.0f, 5.0f);
- DRAW_COLOURED_CYLINDER(x, y, z+1, 1, 1, 0, 0, 255, 255);
- }
- void GetOffset(float distance, float *x, float *y, float *z)
- {
- Vector3 p;
- GET_PED_BONE_POSITION(GetPlayerPed(), BONE_RIGHT_HAND, distance, distance * 0.042, distance * -0.113, &p);
- *x = p.x;
- *y = p.y;
- *z = p.z;
- }
- void Search(void)
- {
- Vehicle Veh;
- bool found = false;
- float search, tx, ty, tz;
- for (search = 1;search<100;search++)
- {
- found = false;
- GetOffset(search, &tx, &ty, &tz);
- Veh = GET_CLOSEST_CAR(tx, ty, tz, 1.5f, 0, 71);
- if (!DOES_VEHICLE_EXIST(Veh))
- {
- Veh = GET_CLOSEST_CAR(tx, ty, tz, 1.5f, 0, 69);
- if (!DOES_VEHICLE_EXIST(Veh))
- Veh = GET_CLOSEST_CAR(tx, ty, tz, 1.5f, 0, 70);
- }
- if (DOES_VEHICLE_EXIST(Veh)){found = true; break;}
- }
- if (found)
- {
- Dostuff(Veh);
- }
- }
- void Searchinit(void)
- {
- if (!HAS_CHAR_GOT_WEAPON(GetPlayerPed(), wGun))
- GIVE_WEAPON_TO_CHAR(GetPlayerPed(), wGun, AMMO_MAX, 0);
- uint Weapon;
- GET_CURRENT_CHAR_WEAPON(GetPlayerPed(), &Weapon);
- if (Weapon != wGun) {DISABLE_PLAYER_LOCKON(GET_PLAYER_ID(), false); return;}
- if (IS_CHAR_IN_ANY_CAR(GetPlayerPed())) return;
- DISABLE_PLAYER_LOCKON(GET_PLAYER_ID(), true);
- if (IS_BUTTON_PRESSED(0, BUTTON_L2))Search();
- }
- void main(void)
- {
- THIS_SCRIPT_IS_SAFE_FOR_NETWORK_GAME();
- while(true)
- {
- Searchinit();
- WAIT(0);
- }
- }
- /*** Example usage
- void Dostuff(Vehicle foundcar)
- {
- if (IS_CHAR_SHOOTING(GetPlayerPed())
- {
- float px, py, pz, cx, cy, cz, fx, fy, fz, dist;
- GET_CHAR_COORDINATES(GetPlayerPed(), &px, &py, &pz);
- GET_CAR_COORDINATES(foundcar, &cx, &cy, &cz);
- GET_DISTANCE_BETWEEN_COORDS_3D(px, py, pz, cx, cy, cz, &dist);
- fx = (cx - px) / dist * 1000;
- fy = (cy - py) / dist * 1000;
- fz = (cz - pz) / dist * 1000;
- APPLY_FORCE_TO_CAR(foundcar, true, fx, fy, fz, 0, 0, 0, true, false, true, true);
- }
- }
- ***/
Advertisement
Add Comment
Please, Sign In to add comment