Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <natives.h>
- #include <common.h>
- #include <strings.h>
- #include <types.h>
- #include <consts.h>
- #define L1 0x4
- #define L2 0x5
- #define R1 0x6
- #define R2 0x7
- #define DPAD_UP 0x8
- #define DPAD_DOWN 0x9
- #define DPAD_LEFT 0xA
- #define DPAD_RIGHT 0xB
- #define START 0xC
- #define SELECT 0xD
- #define SQUARE 0xE
- #define TRIANGLE 0xF
- #define X 0x10
- #define CIRCLE 0x11
- #define STICK_L 0x12 // L3
- #define STICK_R 0x13 // R3
- int justshot = 0;
- int wep;
- Object ObjectProjectile;
- int wepCheck;
- float prjX, prjY, prjZ, prjT, gcX, gcY, gcZ, gcrotX, gcrotY, gcrotZ, objrotX, objrotZ;
- Camera game_cam;
- float charX, charY, charZ , Object_X, Object_Y, Object_Z , dist;
- float expx,expy,expz;
- bool ChangeExpType=2; //Sets to rocket first
- bool exp=0;
- void Print(char *string,uint Time)
- {
- PRINT_STRING_WITH_LITERAL_STRING_NOW("STRING", string, Time, 1);
- }
- void MainLoop()
- {
- GET_CURRENT_CHAR_WEAPON(GetPlayerPed(), &wepCheck);
- if(wep == WEAPON_PISTOL)
- {
- //SET_TEXT_DROPSHADOW(1, 0, 0, 0, 255);
- //SET_TEXT_SCALE(0.2f, 0.2f);
- //DISPLAY_TEXT_WITH_STRING(0.832f, 0.069f, "STRING", "SPECAL");
- 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.0;
- }
- else
- {
- objrotX = gcrotX;
- }
- if (gcrotZ < 0.0)
- {
- objrotZ = gcrotZ + 360.0;
- }
- 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 = (3.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 + (3.0 * SIN(gcrotX)); // calculates how far to spawn the object from the game_cam on the Z plane
- }
- }
- }
- void Actions()
- {
- GET_CURRENT_CHAR_WEAPON(GetPlayerPed(), &wep);
- if((wep == WEAPON_PISTOL) && (IS_CHAR_SHOOTING(GetPlayerPed())))
- {
- REQUEST_MODEL(0x8F2A7EB3);
- while(!HAS_MODEL_LOADED(0x8F2A7EB3))
- {
- WAIT(0);
- }
- CREATE_OBJECT(0x8F2A7EB3, prjX, prjY, prjZ, &ObjectProjectile, 1);
- SET_OBJECT_VISIBLE(ObjectProjectile, 0);
- MARK_MODEL_AS_NO_LONGER_NEEDED(0x8F2A7EB3);
- if(DOES_OBJECT_EXIST(ObjectProjectile))
- {
- SET_OBJECT_AS_STEALABLE(ObjectProjectile, 1);
- SET_OBJECT_ROTATION(ObjectProjectile, objrotX, 0.0, objrotZ);
- SET_OBJECT_RECORDS_COLLISIONS(ObjectProjectile, true);
- SET_OBJECT_DYNAMIC(ObjectProjectile, 1);
- APPLY_FORCE_TO_OBJECT(ObjectProjectile, 1, 0.0, 90.0, 0.0, 0.0, 0.0, 0.0, 1, 1, 1, 1);
- WAIT(100);
- justshot = 1;
- }
- }
- }
- void ExplosionSelec(void)
- {
- if(wep == WEAPON_PISTOL)
- {
- if((exp==0)&& (IS_BUTTON_JUST_PRESSED(0,R1))) { ChangeExpType=1; exp=1; Print("EXPLOSION_MOLOTOV" , 200);}
- else if((exp==1)&& (IS_BUTTON_JUST_PRESSED(0,R1))) { ChangeExpType=2; exp=2; Print("EXPLOSION_ROCKET" , 200);}
- else if((exp==2)&& (IS_BUTTON_JUST_PRESSED(0,R1))) { ChangeExpType=3; exp=3; Print("EXPLOSION_HI_OCTANE" , 200); }
- else if((exp==3)&& (IS_BUTTON_JUST_PRESSED(0,R1))) { ChangeExpType=4; exp=4; Print("EXPLOSION_PETROL_PUMP" , 200);}
- else if((exp==4)&& (IS_BUTTON_JUST_PRESSED(0,R1))) { ChangeExpType=5; exp=0; Print("EXPLOSION_SHIP_DESTROY" , 200);}
- }
- }
- void blowupobject()
- {
- if(justshot==1)
- {
- if (HAS_OBJECT_COLLIDED_WITH_ANYTHING(ObjectProjectile ))
- {
- WAIT(200);
- GET_OBJECT_COORDINATES(ObjectProjectile, &expx,&expy,&expz);
- // press r1 to select explosives
- if(ChangeExpType==1){ ADD_EXPLOSION(expx,expy,expz, EXPLOSION_MOLOTOV, 7.50, 1, 0, 0.7); }
- else if(ChangeExpType==2){ ADD_EXPLOSION(expx,expy,expz, EXPLOSION_ROCKET, 7.50, 1, 0, 0.7); }
- else if(ChangeExpType==3){ ADD_EXPLOSION(expx,expy,expz, EXPLOSION_HI_OCTANE, 7.50, 1, 0, 0.7);}
- else if(ChangeExpType==4){ ADD_EXPLOSION(expx,expy,expz, EXPLOSION_PETROL_PUMP, 7.50, 1, 0, 0.7); }
- else if(ChangeExpType==5){ ADD_EXPLOSION(expx,expy,expz, EXPLOSION_SHIP_DESTROY, 7.50, 1, 0, 0.7); }
- //cleanup object
- if(DOES_OBJECT_EXIST(ObjectProjectile)) { DELETE_OBJECT(&ObjectProjectile);}
- justshot = 0;
- }
- }
- }
- void main(void)
- {
- THIS_SCRIPT_IS_SAFE_FOR_NETWORK_GAME();
- while(true)
- {
- WAIT(0);
- MainLoop();
- Actions();
- ExplosionSelec();
- blowupobject();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment