Advertisement
djhonga2001

GTAV - Sentry Gun

Nov 18th, 2016
464
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. //----------------- Sentry Gun -----------------
  2. //
  3. //Includes a Variable TargetName[] that can be used to either display targeted players name or just "Vehicle"
  4. //Configurable timeout on variable Called:Timeout
  5. //Configurable weapon on variable Called:WeaponID (http://www.*********.com/forums/threads/weapon-and-explosion-hashes-list.1045035/)
  6.  
  7. //You can switch Players as target with bool:PlayerTarget
  8. //you can switch Vehicles as targets with bool:VehicleTarget
  9. //Vehicles always get priority over players
  10. //------------------------------------------------
  11.  
  12.  
  13. float GetPointToPointRotation(Source,Target)
  14. {
  15. return ATAN2((Target.y - Source.y),(Target.x - Source.x));
  16. }
  17.  
  18.  
  19. InitiateSentryGun()
  20. {
  21. int SentryObject = CREATE_OBJECT("p_rcss_folded",--------------------------
  22. int Timeout = 500
  23. Timer = GET_GAME_TIMER() + Timeout
  24. }
  25.  
  26. int GetClosestVehicle(Vector3 Coords,float Distance)
  27. {
  28. Flag = 64;
  29. Flag |= 65536;
  30. Flag |= 2048;
  31. Flag |= 1;
  32. Flag |= 2;
  33. Flag |= 4;
  34. Flag |= 32;
  35. Flag |= 16;
  36. Flag |= 8;
  37. return GET_CLOSEST_VEHICLE(Coords,Distance,0,Flag)
  38. }
  39.  
  40. SentryGunLoop()
  41. {
  42. If (PlayerTarget == True )
  43. {
  44. int TargetID = GET_PLAYER_PED(GET_NEAREST_PLAYER_TO_ENTITY(Sentry Object));
  45. char TargetName[] = GET_PLAYER_NAME(TargetID);
  46. if (TargetID == PLAYER_PED_ID())
  47. {
  48. //Dont Shoot Myself
  49. }
  50. else
  51. {
  52.  
  53. }
  54. }
  55.  
  56. If (VehicleTarget == True )
  57. {
  58. int TargetID = GetClosestVehicle(GET_ENTITY_COORDS(SentryObject,1 ),75);
  59. char TargetName[] = "Vehicle";
  60. if (IS_PED_IN_ANY_VEHICLE(PLAYER_PED_ID(),0) == True );
  61. {
  62. VehID = GET_VEHICLE_PED_IS_IN(PLAYER_PED_ID(),0);
  63. if (TargetID == VehID)
  64. {
  65. //Dont Shoot Myself
  66. }
  67. else
  68. {
  69. }
  70. }
  71. else
  72. {
  73.  
  74. }
  75. }
  76.  
  77. //Rotate and draw
  78. float Rotation = GetPointToPointRotation(SentryObject,TargetID) + 90
  79. SET_ENTITY_ROTATION(SentryObject,0,0,Rotation)
  80. 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)
  81.  
  82. //Time to Kill
  83. if (GET_GAME_TIMER() >= Timer)
  84. { 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)
  85. PLAY_SOUND_FROM_ENTITY(-1,"Remote_Sniper_Rifle_Fire",SentryObject,"",0,0)
  86.  
  87. Timer = GET_GAME_TIMER() + Timeout //500 Milisec between shots
  88. }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement