public override async Task HoldFocus() { // Hide HUD Screen.Hud.IsVisible = false; // Disable the loading screen from automatically being dismissed API.SetManualShutdownLoadingScreenNui(true); // Position character, required for switching Game.Player.Character.Position = Vector3.Zero; // Freeze Game.Player.Freeze(); // Switch out the player if it isn't already in a switch state if (!API.IsPlayerSwitchInProgress()) { API.SwitchOutPlayer(API.PlayerPedId(), 0, 1); } // Remove most clouds API.SetCloudHatOpacity(0.01f); // Wait for switch while (API.GetPlayerSwitchState() != 5) { await Delay(10); } // Hide loading screen API.ShutdownLoadingScreen(); // Fade out Screen.Fading.FadeOut(0); while (Screen.Fading.IsFadingOut) { await Delay(10); } // Show overlay var overlay = new StartOverlay(this.OverlayManager); overlay.Play += OnPlay; // Focus overlay API.SetNuiFocus(true, true); // Shut down the NUI loading screen API.ShutdownLoadingScreenNui(); // Fade in Screen.Fading.FadeIn(500); while (Screen.Fading.IsFadingIn) { await Delay(10); } // Wait for user before releasing focus while (!this.started) { await Delay(20); } }
public override async Task HoldFocus() { // Hide HUD Screen.Hud.IsVisible = false; // Disable the loading screen from automatically being dismissed // No longer works, requires "loadscreen_manual_shutdown 'yes'" in __resource.lua: // https://github.com/citizenfx/fivem/blob/7208a2a63fe5da65ce5ea785032d148ae9354ac1/code/components/loading-screens-five/src/LoadingScreens.cpp#L146 //API.SetManualShutdownLoadingScreenNui(true); // Position character, required for switching Game.Player.Character.Position = Vector3.Zero; // Freeze player Game.Player.Freeze(); // Switch out the player if it isn't already in a switch state if (!API.IsPlayerSwitchInProgress()) { API.SwitchOutPlayer(API.PlayerPedId(), 0, 1); } // Remove most clouds API.SetCloudHatOpacity(0.01f); // Wait for switch while (API.GetPlayerSwitchState() != 5) { await Delay(10); } // Hide loading screen API.ShutdownLoadingScreen(); // Fade out Screen.Fading.FadeOut(0); while (Screen.Fading.IsFadingOut) { await Delay(10); } // Create overlay var overlay = new StartOverlay(this.OverlayManager, this.Catalog); overlay.Play += OnPlay; // Focus overlay this.OverlayManager.Focus(true, true); // Shut down the NUI loading screen API.ShutdownLoadingScreenNui(); // Fade in Screen.Fading.FadeIn(500); while (Screen.Fading.IsFadingIn) { await Delay(10); } // Wait for user before releasing focus while (!this.started) { await Delay(100); } }