SHARE
TWEET

Simple Blur Cam

Eddlm Feb 24th, 2018 167 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using GTA;
  2. using GTA.Math;
  3. using GTA.Native;
  4. using System;
  5. using System.IO;
  6. using System.Windows.Forms;
  7.  
  8.  
  9.  
  10. public class SimpleBlurCam : Script
  11. {
  12.     string ScriptName = "SimpleBlurCam";
  13.     string ScriptVer = "1.0";
  14.  
  15.     public SimpleBlurCam()
  16.     {
  17.         Tick += OnTick;
  18.     }
  19.  
  20.     Camera TestCam = null;
  21.     Camera From = null;
  22.     Vector3 CamRot = Vector3.Zero;
  23.     void OnTick(object sender, EventArgs e)
  24.     {
  25.         if (TestCam != null)
  26.         {
  27.             if(TestCam == World.RenderingCamera) Function.Call(Hash.HIDE_HUD_AND_RADAR_THIS_FRAME);
  28.             else if(GameplayCamera.IsRendering) DisplayHelpTextThisFrame("Press ~INPUT_CONTEXT~ to switch to the BlurCam.");
  29.  
  30.             Vector3 offset = Function.Call<Vector3>(Hash.GET_OFFSET_FROM_ENTITY_GIVEN_WORLD_COORDS, Game.Player.Character, TestCam.Position.X, TestCam.Position.Y, TestCam.Position.Z);
  31.             if (offset.Y < 0)
  32.             {
  33.                 TestCam.Rotation = Game.Player.Character.CurrentVehicle.Rotation - (new Vector3(-CamRot.X, CamRot.Y, CamRot.Z));
  34.             }
  35.             else
  36.             {
  37.                 TestCam.Rotation = Game.Player.Character.CurrentVehicle.Rotation - (new Vector3(CamRot.X, CamRot.Y, CamRot.Z));
  38.             }
  39.         }
  40.         if (Game.IsControlJustPressed(2, GTA.Control.Context))
  41.         {
  42.             if (TestCam == null)
  43.             {
  44.                 if (GameplayCamera.IsRendering) return;
  45.                 if (CanWeUse(Game.Player.Character.CurrentVehicle))
  46.                 {
  47.  
  48.                     TestCam =  World.CreateCamera(Game.Player.Character.Position + (Game.Player.Character.ForwardVector * 10), new Vector3(0, 0, 0), GameplayCamera.FieldOfView);
  49.                     From = World.CreateCamera(GameplayCamera.Position, GameplayCamera.Rotation, GameplayCamera.FieldOfView);
  50.  
  51.                     CamRot = Game.Player.Character.Rotation - new Vector3(-World.RenderingCamera.Rotation.X, World.RenderingCamera.Rotation.Y, World.RenderingCamera.Rotation.Z);
  52.                     TestCam.Position = World.RenderingCamera.Position;
  53.                     TestCam.Rotation = World.RenderingCamera.Rotation;
  54.                     TestCam.FieldOfView = World.RenderingCamera.FieldOfView;
  55.  
  56.                     Camera JoshCam = World.RenderingCamera;
  57.                     Vector3 offset = Function.Call<Vector3>(Hash.GET_OFFSET_FROM_ENTITY_GIVEN_WORLD_COORDS, Game.Player.Character, TestCam.Position.X, TestCam.Position.Y, TestCam.Position.Z);
  58.                     Function.Call(Hash.ATTACH_CAM_TO_ENTITY, TestCam, Game.Player.Character.CurrentVehicle, offset.X, offset.Y, offset.Z, true);
  59.                     UI.ShowSubtitle("~b~BlurCam Created.~n~~y~Exit freecam~w~.", 2000);
  60.                     JoshCam.IsActive = true;
  61.  
  62.                     Function.Call(Hash.SET_ENTITY_MOTION_BLUR, Game.Player.Character.CurrentVehicle, true);
  63.                 }
  64.                 else
  65.                 {
  66.                     UI.ShowSubtitle("~r~You need a vehicle for this to work.");
  67.                 }
  68.             }
  69.             else
  70.             {
  71.                 if (TestCam.Exists() && World.RenderingCamera!= TestCam)
  72.                 {
  73.                     World.RenderingCamera = From;
  74.  
  75.                     From.Position = GameplayCamera.Position;
  76.                     From.Rotation = GameplayCamera.Rotation;
  77.                     From.MotionBlurStrength = 50f;
  78.                     TestCam.MotionBlurStrength = 50f;
  79.                     Function.Call(Hash.SET_CAM_ACTIVE_WITH_INTERP, TestCam, From, 2000, 1, 1);
  80.  
  81.                 }
  82.                 else if (TestCam.Exists() && World.RenderingCamera == TestCam)
  83.                 {
  84.                     TestCam.Destroy();
  85.                     TestCam = null;
  86.                     From.Destroy();
  87.                     UI.ShowSubtitle("~y~Blur Cam destroyed.",1000);
  88.                     Function.Call(Hash.SET_ENTITY_MOTION_BLUR, Game.Player.Character.CurrentVehicle, false);
  89.                 }
  90.             }
  91.         }
  92.     }
  93.  
  94.  
  95.     bool CanWeUse(Entity entity)
  96.     {
  97.         return entity != null && entity.Exists();
  98.     }
  99.  
  100.     void DisplayHelpTextThisFrame(string text)
  101.     {
  102.         Function.Call(Hash._SET_TEXT_COMPONENT_FORMAT, "STRING");
  103.         Function.Call(Hash._ADD_TEXT_COMPONENT_STRING, text);
  104.         Function.Call(Hash._DISPLAY_HELP_TEXT_FROM_STRING_LABEL, 0, false, true, -1);
  105.     }
  106. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top