Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using GTA;
- using GTA.Math;
- using GTA.Native;
- using System;
- using System.IO;
- using System.Windows.Forms;
- public class SimpleBlurCam : Script
- {
- string ScriptName = "SimpleBlurCam";
- string ScriptVer = "1.0";
- public SimpleBlurCam()
- {
- Tick += OnTick;
- }
- Camera TestCam = null;
- Camera From = null;
- Vector3 CamRot = Vector3.Zero;
- void OnTick(object sender, EventArgs e)
- {
- if (TestCam != null)
- {
- if(TestCam == World.RenderingCamera) Function.Call(Hash.HIDE_HUD_AND_RADAR_THIS_FRAME);
- else if(GameplayCamera.IsRendering) DisplayHelpTextThisFrame("Press ~INPUT_CONTEXT~ to switch to the BlurCam.");
- 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);
- if (offset.Y < 0)
- {
- TestCam.Rotation = Game.Player.Character.CurrentVehicle.Rotation - (new Vector3(-CamRot.X, CamRot.Y, CamRot.Z));
- }
- else
- {
- TestCam.Rotation = Game.Player.Character.CurrentVehicle.Rotation - (new Vector3(CamRot.X, CamRot.Y, CamRot.Z));
- }
- }
- if (Game.IsControlJustPressed(2, GTA.Control.Context))
- {
- if (TestCam == null)
- {
- if (GameplayCamera.IsRendering) return;
- if (CanWeUse(Game.Player.Character.CurrentVehicle))
- {
- TestCam = World.CreateCamera(Game.Player.Character.Position + (Game.Player.Character.ForwardVector * 10), new Vector3(0, 0, 0), GameplayCamera.FieldOfView);
- From = World.CreateCamera(GameplayCamera.Position, GameplayCamera.Rotation, GameplayCamera.FieldOfView);
- CamRot = Game.Player.Character.Rotation - new Vector3(-World.RenderingCamera.Rotation.X, World.RenderingCamera.Rotation.Y, World.RenderingCamera.Rotation.Z);
- TestCam.Position = World.RenderingCamera.Position;
- TestCam.Rotation = World.RenderingCamera.Rotation;
- TestCam.FieldOfView = World.RenderingCamera.FieldOfView;
- Camera JoshCam = World.RenderingCamera;
- 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);
- Function.Call(Hash.ATTACH_CAM_TO_ENTITY, TestCam, Game.Player.Character.CurrentVehicle, offset.X, offset.Y, offset.Z, true);
- UI.ShowSubtitle("~b~BlurCam Created.~n~~y~Exit freecam~w~.", 2000);
- JoshCam.IsActive = true;
- Function.Call(Hash.SET_ENTITY_MOTION_BLUR, Game.Player.Character.CurrentVehicle, true);
- }
- else
- {
- UI.ShowSubtitle("~r~You need a vehicle for this to work.");
- }
- }
- else
- {
- if (TestCam.Exists() && World.RenderingCamera!= TestCam)
- {
- World.RenderingCamera = From;
- From.Position = GameplayCamera.Position;
- From.Rotation = GameplayCamera.Rotation;
- From.MotionBlurStrength = 50f;
- TestCam.MotionBlurStrength = 50f;
- Function.Call(Hash.SET_CAM_ACTIVE_WITH_INTERP, TestCam, From, 2000, 1, 1);
- }
- else if (TestCam.Exists() && World.RenderingCamera == TestCam)
- {
- TestCam.Destroy();
- TestCam = null;
- From.Destroy();
- UI.ShowSubtitle("~y~Blur Cam destroyed.",1000);
- Function.Call(Hash.SET_ENTITY_MOTION_BLUR, Game.Player.Character.CurrentVehicle, false);
- }
- }
- }
- }
- bool CanWeUse(Entity entity)
- {
- return entity != null && entity.Exists();
- }
- void DisplayHelpTextThisFrame(string text)
- {
- Function.Call(Hash._SET_TEXT_COMPONENT_FORMAT, "STRING");
- Function.Call(Hash._ADD_TEXT_COMPONENT_STRING, text);
- Function.Call(Hash._DISPLAY_HELP_TEXT_FROM_STRING_LABEL, 0, false, true, -1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement