public void ToggleBombBayView() { if (bombCam == null) { ControlMonitor.DisableControl(Control.VehicleFlyAttack); ControlMonitor.DisableControl(Control.VehicleFlyAttack2); int boneIndex = Function.Call<int>(Hash._GET_ENTITY_BONE_INDEX, vehicle.Handle, "chassis_dummy"); var boneCoord = Function.Call<Vector3>(Hash._GET_ENTITY_BONE_COORDS, vehicle.Handle, boneIndex); bombCam = new Camera(Function.Call<int>(Hash.CREATE_CAMERA_WITH_PARAMS, 0x19286a9, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 65.0f, 0, 2)); bombCam.AttachTo(vehicle, new Vector3(0f, 1.3324f, -0.9f)); bombCam.PointAt(vehicle, vehicle.GetOffsetFromWorldCoords(boneCoord - new Vector3(0, 0, 1.3f))); bombCam.Shake(CameraShake.RoadVibration, 0.4f); bombCam.FieldOfView = 65.0f; bombCam.IsActive = true; Function.Call(Hash.RENDER_SCRIPT_CAMS, 1, 0, 3000, 1, 0, 0); Function.Call(Hash.DISPLAY_RADAR, 0); Function.Call(Hash.DISPLAY_HUD, 0); SetAutopilot(true); } else { World.RenderingCamera = null; bombCam.IsActive = false; bombCam.Destroy(); bombCam = null; Function.Call(Hash.DISPLAY_RADAR, 1); Function.Call(Hash.DISPLAY_HUD, 1); ControlMonitor.EnableControl(Control.VehicleFlyAttack); ControlMonitor.EnableControl(Control.VehicleFlyAttack2); SetAutopilot(false); } }
public void OnTick(object sender, EventArgs e) { var veh = FindNearbyPoliceVehicle(VehicleType.Car); if (veh?.Handle != 0 && !notifyVehicle && World.RenderingCamera.Handle != mainCamera?.Handle) { UI.Notify("Vehicle Cam Available."); notifyVehicle = true; } else if (veh == null || veh.Handle == 0) notifyVehicle = false; veh = FindNearbyPoliceVehicle(VehicleType.Helicopter); if (veh?.Handle != 0 && !notifyHeli && World.RenderingCamera.Handle != mainCamera?.Handle) { UI.Notify("Helicopter Cam Available."); notifyHeli = true; } else if (veh == null || veh.Handle == 0) notifyHeli = false; if (Game.Player.Character.IsOnFoot && Function.Call<int>(Hash.GET_FOLLOW_PED_CAM_VIEW_MODE) == 2 || Game.Player.Character.IsInVehicle() && Function.Call<int>(Hash.GET_FOLLOW_VEHICLE_CAM_VIEW_MODE) == 2) { Function.Call(Hash.DISABLE_CONTROL_ACTION, 0, 0, true); if (Function.Call<bool>(Hash.IS_DISABLED_CONTROL_JUST_PRESSED, 0, 0)) { var player = Game.Player.Character; switch (mViewModeCounter) { case 0: var policeVeh = FindNearbyPoliceVehicle(VehicleType.Car); if (policeVeh != null && policeVeh.Handle != 0) { var boneIndex = Function.Call<int>(Hash._GET_ENTITY_BONE_INDEX, policeVeh.Handle, "windscreen"); var bonePos = Function.Call<Vector3>(Hash._GET_ENTITY_BONE_COORDS, policeVeh.Handle, boneIndex); var camPos = Function.Call<Vector3>(Hash.GET_OFFSET_FROM_ENTITY_GIVEN_WORLD_COORDS, policeVeh.Handle, bonePos.X, bonePos.Y, bonePos.Z); mainCamera = World.CreateCamera(camPos, policeVeh.Rotation, 40f); mainCamera.AttachTo(policeVeh, new Vector3(camPos.X, camPos.Y - 0.3f, camPos.Z - 0.02f)); mainCamera.PointAt(player); World.RenderingCamera = mainCamera; mViewModeCounter++; } else { mViewModeCounter++; goto case1; } break; case 1: case1: var policeHeli = FindNearbyPoliceVehicle(VehicleType.Helicopter); if (policeHeli != null && policeHeli.Handle != 0) { mainCamera = World.CreateCamera(policeHeli.Position, policeHeli.Rotation, 50f); mainCamera.AttachTo(policeHeli, new Vector3(0, 0, -1.4f)); mainCamera.PointAt(player); World.RenderingCamera = mainCamera; mViewModeCounter++; } else { ExitCustomCameraView(); mViewModeCounter = 0; } break; default: ExitCustomCameraView(); mViewModeCounter = 0; break; } } } }