public void addObjective(AbstractObjective objective) { objective.OnFailed += (sender, reason) => { #region Show checkpoint popup var title = reason; var subtitle = "Voulez-vous revenir au dernier checkpoint ?"; ConfirmationPopup checkpointPopup = new ConfirmationPopup(title, subtitle); checkpointPopup.OnPopupAccept += () => { this.loadLastCheckpoint(); }; checkpointPopup.OnPopupRefuse += () => { this.stop(true); }; checkpointPopup.show(); #endregion }; objective.OnAccomplished += (sender, elapsedTime) => { this.next(); }; objectives.Add(objective); }
/// <summary> /// Reset old player model /// </summary> public void resetPlayerModel() { bool playerWasDead = false; bool playerWasArrested = false; Ped player = Game.Player.Character; if ((PedHash)player.Model.Hash != DemagoScript.savedPlayerModelHash) { Vehicle currentVehicle = null; if (player.IsInVehicle()) { currentVehicle = player.CurrentVehicle; } if (player.IsDead || Function.Call<bool>(Hash.IS_PLAYER_BEING_ARRESTED, Game.Player, false)) { #region Create remplacement ped Ped replacementPed = Function.Call<Ped>(Hash.CLONE_PED, Game.Player.Character, Function.Call<int>(Hash.GET_ENTITY_HEADING, Function.Call<int>(Hash.PLAYER_PED_ID)), false, true); if (player.IsDead) { playerWasDead = true; replacementPed.Kill(); } else { playerWasArrested = true; replacementPed.Task.HandsUp(10000); } replacementPed.MarkAsNoLongerNeeded(); #endregion } #region Change player model with saved PedHash var characterModel = new Model(DemagoScript.savedPlayerModelHash); characterModel.Request(500); if (characterModel.IsInCdImage && characterModel.IsValid) { while (!characterModel.IsLoaded) Script.Wait(100); Function.Call(Hash.SET_PLAYER_MODEL, Game.Player, characterModel.Hash); Function.Call(Hash.SET_PED_DEFAULT_COMPONENT_VARIATION, Game.Player.Character.Handle); } characterModel.MarkAsNoLongerNeeded(); #endregion player = Game.Player.Character; if (currentVehicle != null) { player.SetIntoVehicle(currentVehicle, VehicleSeat.Driver); } if ((playerWasDead || playerWasArrested) && DemagoScript.isThereACurrentMission()) { #region Hide real player and wait for game recovery player.IsVisible = false; player.IsInvincible = true; player.Task.StandStill(-1); //Tant qu'on charge le jeu, on fait attendre le script GTA Démago while (!Function.Call<bool>(Hash.IS_PLAYER_PLAYING, Game.Player)) { Script.Wait(100); } player.IsVisible = true; player.IsInvincible = false; #endregion while (!Function.Call<bool>(Hash.IS_PLAYER_CONTROL_ON, Game.Player)) { Script.Wait(100); } #region Show death or arrested popups var title = (playerWasDead) ? "Vous êtes mort" : "Vous vous êtes fait arrêter"; var subtitle = "Voulez-vous revenir au dernier checkpoint ?"; ConfirmationPopup checkpointPopup = new ConfirmationPopup(title, subtitle); checkpointPopup.OnPopupAccept += () => { DemagoScript.loadLastCheckpointOnCurrentMission(); }; checkpointPopup.OnPopupRefuse += () => { DemagoScript.stopCurrentMission(true); }; checkpointPopup.show(); #endregion } } }