Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <natives.h>
- #include <consts.h>
- #include <types.h>
- #include <common.h>
- #define MISSILECOUNT 10
- #define VEHICLECOUNT 10
- #define BUTTON_SELECT 0xD
- #define BUTTON_START 0xC
- #define BUTTON_X 0xE
- #define BUTTON_Y 0xF
- #define BUTTON_A 0x10
- #define BUTTON_B 0x11
- #define DPAD_UP 0x8
- #define DPAD_DOWN 0x9
- #define DPAD_LEFT 0xA
- #define DPAD_RIGHT 0xB
- #define BUTTON_L 0x5
- #define BUTTON_R 0x7
- #define BUTTON_LB 0x4
- #define BUTTON_RB 0x6
- #define STICK_LEFT 0x12
- #define STICK_RIGHT 0x13
- float ground;
- bool online;
- bool search;
- bool get_car;
- Cam game_cam;
- int option,options = 2;
- int i,timer,nvid;
- uint xx,weapon;
- Ped online_char;
- Vehicle closest_car,pveh,car,closest;
- uint model;
- Object ObjectProjectile;
- bool pressed;
- int ModePointer = 0;
- Vehicle MissileQueue[MISSILECOUNT];
- Vehicle VehicleQueue[VEHICLECOUNT];
- int VehiclePointer = 0;
- bool looped;
- Vehicle pveh;
- float px,py,pz,car_x,car_y,car_z,x,y,z,dist,prjX, prjY, prjZ, prjT,coord_x,coord_y,coord_z,
- gcX,gcY,gcZ,gcrotX,gcrotY,gcrotZ,objrotX,objrotZ,heading,qx,qy,qz;
- void print(char* text){
- CLEAR_PRINTS();
- PRINT_STRING_WITH_LITERAL_STRING_NOW("STRING", text,1500, true);
- }
- void scalevector(float *x, float *y, float *z, float scale)
- {
- if (*x != 0 || *y != 0 || *z != 0)
- {
- float Dist = SQRT(POW(*x,2) + POW(*y,2) + POW(*z,2));
- *x = (*x / Dist) * scale;
- *y = (*y / Dist) * scale;
- *z = (*z / Dist) * scale;
- }
- }
- Vehicle GetClosestCar(float x, float y, float z, float dist)
- {
- Vehicle tVeh;
- int i = 69;
- for (;i<=71;i++)
- {
- tVeh = GET_CLOSEST_CAR(x, y, z, dist, 0, i);
- if (DOES_VEHICLE_EXIST(tVeh))return tVeh;
- }
- return INVALID_HANDLE;
- }
- bool network_control(int netid){
- uint tick = 0;
- REQUEST_CONTROL_OF_NETWORK_ID(netid);
- do{
- tick++;
- REQUEST_CONTROL_OF_NETWORK_ID(netid);
- SET_NETWORK_ID_CAN_MIGRATE(netid, true);
- if(HAS_CONTROL_OF_NETWORK_ID(netid)){
- return true;
- }
- else{
- WAIT(0);
- }
- } while(tick < 20);
- return false;
- }
- void object_aim(void){
- GET_GAME_CAM(&game_cam);
- if (IS_CAM_ACTIVE(game_cam)){
- GET_CAM_ROT(game_cam, &gcrotX, &gcrotY, &gcrotZ);// used for setting the object rotation and for some weird trig stuff below
- GET_CAM_POS(game_cam, &gcX, &gcY, &gcZ);// used for the spawn point of the object, because the player is offset while aiming
- if (gcrotX < 0.0)// the range for cam rot is -180 to 180, to set object rot we need 0 to 360
- {
- objrotX = gcrotX + 360.0f;
- }
- else
- {
- objrotX = gcrotX;
- }
- if (gcrotZ < 0.0)
- {
- objrotZ = gcrotZ + 360.0f;
- }
- else
- {
- objrotZ = gcrotZ;
- }
- /* the trig stuff below could possibly be replaced with vectors, I have no idea how to do that though. *
- * I apologize if this is confusing, but if you want to change the distance from the game_cam that the *
- * object is spawned, adjust "3.0" to your preference on the first and fourth lines. Also prjT is the *
- * adjacent side from the pitch calculation, its purpose is to be the tangent in the following 2 lines */
- prjT = (6.0 * COS(gcrotX));// adj side calculation to be used as a tangent below
- prjX = gcX - (prjT * SIN(gcrotZ));// calculates how far to spawn the object from the game_cam on the X plane
- prjY = gcY + (prjT * COS(gcrotZ));// calculates how far to spawn the object from the game_cam on the Y plane
- prjZ = gcZ + (6.0 * SIN(gcrotX)); // calculates how far to spawn the object from the game_cam on the Z plane
- }
- }
- float cx,cy,cz;
- void looped_shit(void){
- GET_CURRENT_CHAR_WEAPON(GetPlayerPed(),&weapon);
- if(weapon == WEAPON_DEAGLE){
- GET_OFFSET_FROM_CHAR_IN_WORLD_COORDS(GetPlayerPed(),0,0,0,&x,&y,&z);
- if(IS_BUTTON_PRESSED(0,BUTTON_L) && IS_BUTTON_JUST_PRESSED(0,BUTTON_R)){
- if(DOES_VEHICLE_EXIST(closest)){
- if(network_control(nvid)){
- FREEZE_CAR_POSITION(closest, false);
- float cx, cy, cz, fx, fy, fz;
- GET_CAR_COORDINATES(closest, &cx, &cy, &cz);
- GET_DISTANCE_BETWEEN_COORDS_3D(cx, cy, cz, x, y, z, &dist);
- fx = (cx - gcX) / dist * 1000;
- fy = (cy - gcY) / dist * 1000;
- fz = (cz - gcZ) / dist * 1000;
- scalevector(&fx, &fy, &fz, 1000);
- APPLY_FORCE_TO_CAR(closest, 3, fx, fy, fz, 0, 0, 0, true, false, true, true);
- WAIT(100);
- if(options == 1){
- SET_PETROL_TANK_HEALTH(closest, -1);
- }
- search = true;
- LOCK_CAR_DOORS(closest, 0);
- car = INVALID_HANDLE;
- closest = INVALID_HANDLE;
- WAIT(500);
- }
- }
- }
- else if(IS_BUTTON_PRESSED(0,BUTTON_L) && !IS_BUTTON_PRESSED(0,BUTTON_R)){
- if(!online){
- Vehicle car = GetClosestCar(x, y, z, 500);
- if(closest == INVALID_HANDLE){
- closest = car;
- }
- if(DOES_VEHICLE_EXIST(closest)){
- object_aim();
- GET_NETWORK_ID_FROM_VEHICLE(closest, &nvid);
- if(network_control(nvid)){
- GET_GROUND_Z_FOR_3D_COORD(prjX, prjY, 1000,&ground);
- FREEZE_CAR_POSITION(closest, true);
- GET_CHAR_HEADING(GetPlayerPed(),&heading);
- heading += 90;
- if(heading > 360.0) heading -= 360.0;
- if(prjZ > ground+0.7){
- SET_CAR_HEADING(closest,heading);
- SET_CAR_COORDINATES_NO_OFFSET(closest,prjX,prjY,prjZ);
- LOCK_CAR_DOORS(closest, 4);
- }
- else{
- SET_CAR_HEADING(closest,heading);
- SET_CAR_COORDINATES(closest,prjX,prjY,prjZ);
- LOCK_CAR_DOORS(closest, 4);
- }
- }
- }
- }
- else{
- if(search){
- for(i = 0; i<16; i++){
- if(!IS_NETWORK_PLAYER_ACTIVE(i)) continue;
- if (i == GetPlayerIndex()) continue;
- GET_PLAYER_CHAR(i, &online_char);
- if(!DOES_CHAR_EXIST(online_char)) continue;
- if(IS_CHAR_IN_ANY_CAR(online_char)){
- GET_CAR_CHAR_IS_USING(online_char,&car);
- GET_OFFSET_FROM_CHAR_IN_WORLD_COORDS(online_char, 0, 0, 0, &qx, &qy, &qz);
- GET_DISTANCE_BETWEEN_COORDS_3D(qx, qy, qz, x, y, z, &dist);
- if(dist <= 50){
- GET_NETWORK_ID_FROM_VEHICLE(car, &nvid);
- if(network_control(nvid)){
- if(closest == INVALID_HANDLE){
- closest = car;
- search = false;
- return;
- }
- }
- }
- }
- }
- }
- if(DOES_VEHICLE_EXIST(closest)){
- object_aim();
- GET_NETWORK_ID_FROM_VEHICLE(closest, &nvid);
- if(network_control(nvid)){
- GET_GROUND_Z_FOR_3D_COORD(prjX, prjY, prjZ,&ground);
- FREEZE_CAR_POSITION(closest, true);
- GET_CHAR_HEADING(GetPlayerPed(),&heading);
- heading += 90;
- if(heading > 360) heading -= 360;
- if(prjZ > ground+0.7){
- SET_CAR_HEADING(closest,heading);
- SET_CAR_COORDINATES_NO_OFFSET(closest,prjX,prjY,prjZ);
- }
- else{
- SET_CAR_HEADING(closest,heading);
- SET_CAR_COORDINATES(closest,prjX,prjY,prjZ);
- }
- LOCK_CAR_DOORS(closest, 4);
- }
- }
- }
- }
- else if(IS_BUTTON_JUST_PRESSED(0,STICK_RIGHT)){
- if(online){
- online = false;
- print("Ped Cars Mode: ~g~ON");
- }
- else{
- online = true;
- search = true;
- print("Online Players Cars Mode: ~g~ON");
- }
- }
- else if(IS_BUTTON_JUST_PRESSED(0,STICK_LEFT)){
- if(options == 1){
- options = 2;
- print("Car will now ~r~ not~w~ be on fire when u shoot");
- }
- else if(options == 2){
- options = 1;
- print("Car will now be on fire when u shoot");
- }
- }
- if(!IS_BUTTON_PRESSED(0,BUTTON_L)){
- if(DOES_VEHICLE_EXIST(closest)){
- FREEZE_CAR_POSITION(closest, false);
- LOCK_CAR_DOORS(closest, 0);
- closest = INVALID_HANDLE;
- car = INVALID_HANDLE;
- search = true;
- }
- }
- }
- }
- void main(void){
- THIS_SCRIPT_IS_SAFE_FOR_NETWORK_GAME();
- GIVE_WEAPON_TO_CHAR(GetPlayerPed(), WEAPON_DEAGLE, AMMO_MAX, false);
- SET_CURRENT_CHAR_WEAPON(GetPlayerPed(), WEAPON_DEAGLE, true);
- DISABLE_PLAYER_LOCKON(GET_PLAYER_ID(), true);
- print("Gravity gun Made by: ~y~Motions97");
- WAIT(1500);
- print("Press ~PAD_RSTICK_ALL~ to cycle through Online and Peds,Press ~PAD_LSTICK_ALL~ to set car that you shoot on fire");
- do{
- if(IS_CHAR_ON_FOOT(GetPlayerPed())){
- looped_shit();
- }
- WAIT(0);
- }while(true);
- }
Advertisement
Add Comment
Please, Sign In to add comment