public override async Task HoldFocus() { // Hide HUD Screen.Hud.IsVisible = false; // Disable the loading screen from automatically being dismissed API.SetManualShutdownLoadingScreenNui(true); // 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); } // Position character, required for switching Game.Player.Character.Position = CitizenFX.Core.Vector3.Zero; // Get characters var characters = await this.Comms.Event(CharacterEvents.GetAllForUser).ToServer().Request <List <Character> >(); // Show overlay this.overlay = new CharactersOverlay(characters, this.OverlayManager); this.overlay.CreateCharacterEvent += OnCreateCharacter; this.overlay.DisconnectEvent += OnDisconnect; this.overlay.SelectCharacterEvent += OnSelectCharacter; this.overlay.DeleteCharacterEvent += OnDeleteCharacter; // Focus overlay this.overlay.Focus(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); } }
private async Task ShowCharacterSelectionScreen() { // If the player had an active character session if (this.characterSession != null) { this.Comms.Event(CharacterEvents.Deselected).ToClient().Emit(this.characterSession); } // Set as not playing this.isCurrentlyPlaying = false; // Hide HUD Screen.Hud.IsVisible = false; // Remove most clouds API.SetCloudHatOpacity(0.01f); // Switch out the player if it isn't already in a switch state if (!API.IsPlayerSwitchInProgress()) { API.SwitchOutPlayer(API.PlayerPedId(), 0, 1); } // Wait for switch while (API.GetPlayerSwitchState() != 5) { await Delay(10); } // Freeze Game.Player.Freeze(); // Fade out Screen.Fading.FadeOut(1000); while (Screen.Fading.IsFadingOut) { await Delay(10); } // Position character, required for switching Game.Player.Character.Position = CitizenFX.Core.Vector3.Zero; // Get characters var characters = await this.Comms.Event(CharacterEvents.GetAllForUser).ToServer().Request <List <Character> >(); // Show overlay this.overlay = new CharactersOverlay(characters, this.OverlayManager); this.overlay.CreateCharacterEvent += OnCreateCharacter; this.overlay.DisconnectEvent += OnDisconnect; this.overlay.SelectCharacterEvent += OnSelectCharacter; this.overlay.DeleteCharacterEvent += OnDeleteCharacter; // Focus overlay this.overlay.Focus(true); // Fade in Screen.Fading.FadeIn(500); while (Screen.Fading.IsFadingIn) { await Delay(10); } }