Advertisement
djhonga2001

Advanced Gravity Gun and Object Removal

Nov 18th, 2016
412
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.78 KB | None | 0 0
  1. // REQUiRMENTS
  2.  
  3.  
  4. Vector3 GetCoordsInfrontOfCam(float distance)
  5. {
  6. Vector3 GameplayCamRot = GET_GAMEPLAY_CAM_ROT(2);
  7. Vector3 GameplayCamCoord = GET_GAMEPLAY_CAM_COORD();
  8.  
  9. float tan = Cos(GameplayCamRot.X) * distance);
  10. float xPlane = Sin(GameplayCamRot.Z * -1.0f) * tan) + GameplayCamCoord.X);
  11. float yPlane = Cos(GameplayCamRot.Z * -1.0f) * tan) + GameplayCamCoord.Y);
  12. float zPlane = Sin(GameplayCamRot.X) * distance) + GameplayCamCoord.Z);
  13.  
  14. return new Vector3(xPlane, yPlane, zPlane);
  15. }
  16.  
  17.  
  18.  
  19. //----------------- Remove targetted Objects -----------------
  20. //
  21. // Just enable RemoveObjects Bool and shoot an object to remove it ( Client Sided )
  22. //
  23. //-----------------------------------------------------
  24.  
  25.  
  26. RemoveObjectsLoop()
  27. {
  28. if ( (RemoveObjects == true) && (IS_CONTROL_PRESSED(2,199) )
  29. {
  30. GET_ENTITY_PLAYER_IS_FREE_AIMING_AT(PLAYER_ID(),*E ntityID)
  31. if (IS_ENTITY_AN_OBJECT(EntityID) == true )
  32. {
  33. DELETE_ENTITY(*EntityID)
  34. }
  35. }
  36. }
  37.  
  38.  
  39. //----------------- Gravity gun ( Pickup and launch ) -----------------
  40. //
  41. // Just enable GravityGun Bool and shoot an object to pick it up shoot again to launch it
  42. //
  43. // When object is picked up it makes it see through and undoes this when launched ( object moves infront of you when picked up )
  44. // ObjectHash[] can be used to display Hash of picked up object ( usefull for spawning uknown object Best display this in lower left under radar )
  45. //
  46. //-----------------------------------------------------
  47.  
  48. Bool Pickup = true
  49.  
  50. GravityGunLoop()
  51. {
  52. if (GravityGun == true)
  53. {
  54. if ( (Pickup == true) && (IS_CONTROL_PRESSED(2,199) )
  55. {
  56. Pickup = false
  57. GET_ENTITY_PLAYER_IS_FREE_AIMING_AT(PLAYER_ID(),*E ntityID)
  58. if (IS_ENTITY_A_PED(EntityID) == true)
  59. {
  60. if (IS_PED_IN_ANY_VEHICLE(EntityID,0))
  61. {
  62. EntityID = GET_VEHICLE_PED_IS_IN(EntityID,0)
  63. }
  64. }
  65. SET_ENTITY_ALPHA(EntityID,200)
  66. }
  67. elseif ( (Pickup == false) && (IS_CONTROL_PRESSED(2,199) )
  68. {
  69. Pickup = true
  70. if (IS_ENTITY_A_PED(EntityID) == true )
  71. {
  72. SET_ENTITY_DYNAMIC(EntityID,1)
  73. Vector3 Rotation = GET_ENTITY_ROTATION(EntityID,2)
  74. SET_ENTITY_ROTATION(EntityID,GET_GAMEPLAY_CAM_ROT( 2),2,1)
  75. APPLY_FORCE_TO_ENTITY(EntityID,1,0,150,0,0,0,0,0,1 ,1,1,0,1)
  76. SET_ENTITY_ROTATION(EntityID,Rotation,2,1)
  77. SET_ENTITY_ALPHA(EntityID,255)
  78. }
  79. }
  80. else
  81. {
  82. if (DOES_ENTITY_EXIST(EntityID)==true)
  83. {
  84. Char ObjectHash[] = GET_ENTITY_MODEL(EntityID)
  85. SET_ENTITY_COORDS(EntityID,GetCoordsInfrontOfCam(1 0),1,0,0,1)
  86. }
  87. }
  88. }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement