Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //----------------- Sentry Gun -----------------
- //
- //Includes a Variable TargetName[] that can be used to either display targeted players name or just "Vehicle"
- //Configurable timeout on variable Called:Timeout
- //Configurable weapon on variable Called:WeaponID (http://www.*********.com/forums/threads/weapon-and-explosion-hashes-list.1045035/)
- //You can switch Players as target with bool:PlayerTarget
- //you can switch Vehicles as targets with bool:VehicleTarget
- //Vehicles always get priority over players
- //------------------------------------------------
- float GetPointToPointRotation(Source,Target)
- {
- return ATAN2((Target.y - Source.y),(Target.x - Source.x));
- }
- InitiateSentryGun()
- {
- int SentryObject = CREATE_OBJECT("p_rcss_folded",--------------------------
- int Timeout = 500
- Timer = GET_GAME_TIMER() + Timeout
- }
- int GetClosestVehicle(Vector3 Coords,float Distance)
- {
- Flag = 64;
- Flag |= 65536;
- Flag |= 2048;
- Flag |= 1;
- Flag |= 2;
- Flag |= 4;
- Flag |= 32;
- Flag |= 16;
- Flag |= 8;
- return GET_CLOSEST_VEHICLE(Coords,Distance,0,Flag)
- }
- SentryGunLoop()
- {
- If (PlayerTarget == True )
- {
- int TargetID = GET_PLAYER_PED(GET_NEAREST_PLAYER_TO_ENTITY(Sentry Object));
- char TargetName[] = GET_PLAYER_NAME(TargetID);
- if (TargetID == PLAYER_PED_ID())
- {
- //Dont Shoot Myself
- }
- else
- {
- }
- }
- If (VehicleTarget == True )
- {
- int TargetID = GetClosestVehicle(GET_ENTITY_COORDS(SentryObject,1 ),75);
- char TargetName[] = "Vehicle";
- if (IS_PED_IN_ANY_VEHICLE(PLAYER_PED_ID(),0) == True );
- {
- VehID = GET_VEHICLE_PED_IS_IN(PLAYER_PED_ID(),0);
- if (TargetID == VehID)
- {
- //Dont Shoot Myself
- }
- else
- {
- }
- }
- else
- {
- }
- }
- //Rotate and draw
- float Rotation = GetPointToPointRotation(SentryObject,TargetID) + 90
- SET_ENTITY_ROTATION(SentryObject,0,0,Rotation)
- DRAW_LINE(GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(S entryObject,0,-0.2,0.57),GET_ENTITY_COORDS(TargetID,1),255,0,0,0)
- //Time to Kill
- if (GET_GAME_TIMER() >= Timer)
- { SHOOT_SINGLE_BULLET_BETWEEN_COORDS(GET_OFFSET_FROM _ENTITY_IN_WORLD_COORDS(SentryObject,0,-0.8,0.6),GET_ENTITY_COORDS(TargetID,1)250,0,Weapon ID,PLAYER_PED_ID(),1,0,float 1.0)
- PLAY_SOUND_FROM_ENTITY(-1,"Remote_Sniper_Rifle_Fire",SentryObject,"",0,0)
- Timer = GET_GAME_TIMER() + Timeout //500 Milisec between shots
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement