예제 #1
0
        public void onKeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.F3)
            {
                if (_menuPool.IsAnyMenuOpen())
                {
                    _menuPool.CloseAllMenus();
                }
                else
                {
                    _menu.Visible = true;
                }
            }

            if (e.KeyCode == Keys.K)
            {
                Player player = Game.Player;
                Model  model  = new Model("prop_money_bag_01");
                model.Request(50);

                if (model.IsInCdImage && model.IsValid)
                {
                    while (!model.IsLoaded)
                    {
                        Script.Wait(50);
                    }
                    World.CreatePickup(PickupType.MoneyPaperBag, player.Character.GetOffsetInWorldCoords(new Vector3(0, 2, 0)), model, 40000);
                }
                else
                {
                    UI.ShowSubtitle("Model is not valid");
                }
            }

            modules.ForEach(mod =>
            {
                if (e.KeyCode == mod.getToggleKey())
                {
                    mod.toggle();
                }
            });
        }
예제 #2
0
        /*
         * Sets up the submenu that displays user's playlist names
         * The playlist names are retrieved from API
         */
        private void SetupPlaylistMenu()
        {
            playlistSubMenu = modMenuPool.AddSubMenu(mainMenu, "Set Radio Playlist");

            UIMenuItem refresh = new UIMenuItem("Refresh Playlists");

            playlistSubMenu.AddItem(refresh);

            List <dynamic> playlistNames = new List <dynamic>();
            List <string>  playlistUris  = new List <string>();

            RefreshPlaylists(playlistNames, playlistUris);
            playlistSubMenu.AddItem(playlistList);

            UIMenuItem setPlaylist = new UIMenuItem("Confirm Selection");

            playlistSubMenu.AddItem(setPlaylist);

            playlistSubMenu.RefreshIndex();


            playlistSubMenu.OnItemSelect += (sender, item, index) =>
            {
                if (item == setPlaylist)
                {
                    int listIndex = playlistList.Index;
                    if (listIndex == 0)
                    {
                        spotify.ResumePlayback("");
                    }
                    else
                    {
                        spotify.ResumePlayback(playlistUris[listIndex]);
                    }
                    time = (int)(moodUpdateTime - GTA.Game.FPS);
                    modMenuPool.CloseAllMenus();
                }
                else if (item == refresh)
                {
                    RefreshPlaylists(playlistNames, playlistUris);
                    playlistSubMenu.RemoveItemAt(deviceListIndex);
                    playlistSubMenu.RemoveItemAt(deviceListIndex);
                    playlistSubMenu.AddItem(playlistList);
                    playlistSubMenu.AddItem(setPlaylist);
                    playlistSubMenu.RefreshIndex();
                }
            };
        }
예제 #3
0
        public GameMenu()
        {
            mainMenu = new UIMenu("Air Superiority", "BETA");
            var menuItem = new UIMenuItem("~g~Start Script");

            menuItem.Activated += (x, y) => { GameManager.InitializeScript(); menuPool.CloseAllMenus(); };
            mainMenu.AddItem(menuItem);
            menuItem            = new UIMenuItem("~r~Stop Script");
            menuItem.Activated += (x, y) => GameManager.StopScript();
            mainMenu.AddItem(menuItem);
            menuItem         = new UIMenuItem("Unlocks (coming soon)");
            menuItem.Enabled = false;
            mainMenu.AddItem(menuItem);
            menuItem = new UIMenuItem("View Stats");
            mainMenu.AddItem(menuItem);
            statsMenu           = new UIMenu("Player Stats", Game.Player.Name);
            menuItem            = new UIMenuItem("Load Stats");
            menuItem.Activated += (x, y) => LoadStatsMenu();
            statsMenu.AddItem(menuItem);
            menuItem         = new UIMenuItem("Player Kills: --");
            menuItem.Enabled = false;
            statsMenu.AddItem(menuItem);
            menuItem         = new UIMenuItem("Player Deaths: --");
            menuItem.Enabled = false;
            statsMenu.AddItem(menuItem);
            menuItem         = new UIMenuItem("Total Score: --");
            menuItem.Enabled = false;
            statsMenu.AddItem(menuItem);
            mainMenu.BindMenuToItem(statsMenu, mainMenu.MenuItems[3]);
            mainMenu.OnItemSelect += MainMenu_OnItemSelect;
            mainMenu.RefreshIndex();
            menuPool = new MenuPool();
            menuPool.Add(mainMenu);
            menuPool.Add(statsMenu);
            KeyDown += KeyPressed;
            Tick    += OnTick;
        }
예제 #4
0
 void onKeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.F5 && !modMenuPool.IsAnyMenuOpen())
     {
         mainMenu.Visible = !mainMenu.Visible;
     }
     else if (e.KeyCode == Keys.F5)
     {
         modMenuPool.CloseAllMenus();
     }
     else if (e.KeyCode == Keys.J)
     {
         if (Game.Player.Character.IsInVehicle())
         {
             Vehicle vehicle = Game.Player.Character.CurrentVehicle;
             if (vehicle.HasSiren && sirens.ContainsKey(vehicle))
             {
                 bool silent;
                 sirens.TryGetValue(vehicle, out silent);
                 vehicle.IsSirenSilent = !silent;
                 sirens.Remove(vehicle);
                 sirens.Add(vehicle, !silent);
             }
             else if (vehicle.HasSiren)
             {
                 bool silent = true;
                 vehicle.IsSirenSilent = silent;
                 sirens.Add(vehicle, silent);
             }
         }
     }
     else
     {
         Outfits.OnKeyDown(e.KeyCode);
     }
 }
예제 #5
0
        private static void OnItemSelect(UIMenu sender, UIMenuItem selectedItem, int index)
        {
            //if (sender == ChecksMenu)
            //{

            //    if (selectedItem == CheckCourtResultsItem)
            //    {
            //        sender.Visible = false;
            //        CourtsMenu.Visible = true;

            //    }
            //}
            if (sender == TrafficStopMenu)
            {
                if (selectedItem == SpeechItem)
                {
                    string speech = SpeechItem.Collection[SpeechItem.Index].Value.ToString();
                    CurrentEnhancedTrafficStop.PlaySpecificSpeech(speech);
                }
                else if (selectedItem == IDItem)
                {
                    //Ask for ID

                    CurrentEnhancedTrafficStop.AskForID((EnhancedTrafficStop.OccupantSelector)IDItem.Index);
                }
                else if (selectedItem == QuestionDriverItem)
                {
                    sender.Visible = false;

                    UpdateTrafficStopQuestioning();
                    QuestioningMenu.Visible = true;
                }
                else if (selectedItem == PenaltyItem)
                {
                    //Issue ticket(bind menu to item)?
                    sender.Visible = false;
                    //Menus.UpdateTicketReasons();
                    updatePenaltyType(IssueTicketItem.Index);
                    TicketMenu.Visible = true;
                }
                else if (selectedItem == WarningItem)
                {
                    //Let driver go
                    CurrentEnhancedTrafficStop.IssueWarning();
                    _MenuPool.CloseAllMenus();
                }
                else if (selectedItem == OutOfVehicleItem)
                {
                    //Order driver out
                    CurrentEnhancedTrafficStop.OutOfVehicle((EnhancedTrafficStop.OccupantSelector)OutOfVehicleItem.Index);
                    _MenuPool.CloseAllMenus();
                }
            }

            else if (sender == TicketMenu)
            {
                if (selectedItem == IssueTicketItem)
                {
                    //Issue TOR

                    bool SeizeVehicle = SeizeVehicleTicketCheckboxItem.Checked;
                    if (Functions.IsPlayerPerformingPullover())
                    {
                        CurrentEnhancedTrafficStop.IssueTicket(SeizeVehicle);
                    }
                    else
                    {
                        GameFiber.StartNew(delegate
                        {
                            EnhancedTrafficStop.performTicketAnimation();
                        });
                    }

                    _MenuPool.CloseAllMenus();
                }
                else if (selectedItem == TicketOffenceSelectorItem)
                {
                    sender.Visible = false;
                    OpenOffencesMenu(sender, CurrentEnhancedTrafficStop.SelectedOffences);
                }
            }
            else if (sender == QuestioningMenu)
            {
                if (selectedItem == IllegalInVehQuestionItem)
                {
                    Game.DisplaySubtitle("~h~" + CurrentEnhancedTrafficStop.AnythingIllegalInVehAnswer);
                }
                else if (selectedItem == DrinkingQuestionItem)
                {
                    Game.DisplaySubtitle("~h~" + CurrentEnhancedTrafficStop.DrinkingAnswer);
                }
                else if (selectedItem == DrugsQuestionItem)
                {
                    Game.DisplaySubtitle("~h~" + CurrentEnhancedTrafficStop.DrugsAnswer);
                }
                else if (selectedItem == SearchPermissionItem)
                {
                    Game.DisplaySubtitle("~h~" + CurrentEnhancedTrafficStop.SearchVehAnswer);
                }
                else if (CustomQuestionsItems.Contains(selectedItem))
                {
                    Game.DisplaySubtitle("~h~" + CurrentEnhancedTrafficStop.CustomQuestionsWithAnswers[CustomQuestionsItems.IndexOf(selectedItem)].Item2);
                }
                else if (CustomQuestionsCallbacksAnswersItems.Contains(selectedItem))
                {
                    Game.DisplaySubtitle("~h~" + CurrentEnhancedTrafficStop.CustomQuestionsWithCallbacksAnswers[CustomQuestionsCallbacksAnswersItems.IndexOf(selectedItem)].Item2(CurrentEnhancedTrafficStop.Suspect));
                }
                else if (CustomQuestionsAnswersCallbackItems.Contains(selectedItem))
                {
                    string Text = CurrentEnhancedTrafficStop.CustomQuestionsAnswerWithCallbacks[CustomQuestionsAnswersCallbackItems.IndexOf(selectedItem)].Item2;
                    Game.DisplaySubtitle("~h~" + Text);

                    CurrentEnhancedTrafficStop.CustomQuestionsAnswerWithCallbacks[CustomQuestionsAnswersCallbackItems.IndexOf(selectedItem)].Item3(CurrentEnhancedTrafficStop.Suspect, Text);
                }
            }
        }
예제 #6
0
        private void OnRenderCharacterList(object[] args)
        {
            if (args.Length < 2)
            {
                return;
            }

            _charList       = JsonConvert.DeserializeObject <List <CharDisplay> >(args[0] as string);
            _selectedCharId = (int)args[1];

            _charMenu = new MenuPool();

            var p = new Point(1350, 200);

            var menu = new UIMenu("Char Select", "Select a character", p);

            _charMenu.Add(menu);

            foreach (var c in _charList)
            {
                var ch = new UIMenuItem($"{c.CharName}");
                menu.AddItem(ch);
            }

            var spawnCharItem = new UIMenuColoredItem("Spawn Character", Color.DarkCyan, Color.LightBlue);

            menu.AddItem(spawnCharItem);

            var createCharItem = new UIMenuColoredItem("Create New Character", Color.CadetBlue, Color.LightBlue);

            menu.AddItem(createCharItem);


            menu.OnItemSelect += (sender, item, index) =>
            {
                if (item == createCharItem)
                {
                    Events.CallLocal("createchar");
                    _charMenu.CloseAllMenus();
                    return;
                }
                if (item == spawnCharItem)
                {
                    if (_selectedCharId < 0)
                    {
                        return;
                    }
                    SpawnChar(null);
                    _charMenu.CloseAllMenus();
                    return;
                }

                var selectedChar = _charList.Find(c => c.CharName == item.Text);
                SelectChar(new object[] { selectedChar.CharID });
            };

            menu.Visible = true;

            if (_selectedCharId >= 0)
            {
                SelectChar(new object[] { _selectedCharId });
            }
        }
예제 #7
0
        private static void OnItemSelect(UIMenu sender, UIMenuItem selectedItem, int index)
        {
            Statuses     statuses     = new Statuses();
            TS10_11Funcs ts10_11Funcs = new TS10_11Funcs();

            if (sender == generalMenu && selectedItem == menu10_11List)
            {
            }
            else
            {
                _MenuPool.CloseAllMenus();
            }
            if (sender == mainMenu)
            {
                if (selectedItem == menu10_99Item)
                {
                    statuses.ShowMe10_99();
                }
            }
            if (sender == generalMenu)
            {
                if (selectedItem == menu10_11List)
                {
                    string selectedListItem = menu10_11List.SelectedItem.ToString();
                    if (selectedListItem == "Occupied x1")
                    {
                        ts10_11Funcs.ShowMe10_11O1();
                    }
                    if (selectedListItem == "Occupied x2")
                    {
                        ts10_11Funcs.ShowMe10_11O2();
                    }
                    if (selectedListItem == "Occupied x3")
                    {
                        ts10_11Funcs.ShowMe10_11O3();
                    }
                    if (selectedListItem == "Occupied x4")
                    {
                        ts10_11Funcs.ShowMe10_11O4();
                    }
                }
                else if (selectedItem == menu10_15Item)
                {
                    statuses.ShowMe10_15();
                }
                else if (selectedItem == menu10_19Item)
                {
                    statuses.ShowMe10_19();
                }
                else if (selectedItem == menu10_23Item)
                {
                    statuses.ShowMe10_23();
                }
                else if (selectedItem == menuCode5Item)
                {
                    statuses.ShowMeCode5();
                }
                else if (selectedItem == menuAffirmativeItem)
                {
                    statuses.Affirmative();
                }
                else if (selectedItem == menuNegativeItem)
                {
                    statuses.Negative();
                }
            }
            if (sender == serviceMenu)
            {
                if (selectedItem == menu10_5Item)
                {
                    statuses.ShowMe10_5();
                }
                else if (selectedItem == menu10_6Item)
                {
                    statuses.ShowMe10_6();
                }
                else if (selectedItem == menu10_7Item)
                {
                    statuses.ShowMe10_7();
                }
                else if (selectedItem == menu10_8Item)
                {
                    statuses.ShowMe10_8();
                }
                else if (selectedItem == menu10_41Item)
                {
                    statuses.ShowMe10_41();
                }
                else if (selectedItem == menu10_42Item)
                {
                    statuses.ShowMe10_42();
                }
            }
            if (sender == backupMenu)
            {
                if (selectedItem == menu10_32List)
                {
                    string selectedListItem = menu10_32List.SelectedItem.ToString();
                    if (selectedListItem == "Code 2")
                    {
                        statuses.Requesting10_32C2();
                    }
                    else if (selectedListItem == "Code 3")
                    {
                        statuses.Requesting10_32C3();
                    }
                    else if (selectedListItem == "Female")
                    {
                        statuses.Requesting10_32F();
                    }
                }
                else if (selectedItem == menu10_51Item)
                {
                    statuses.Requesting10_51();
                }
                else if (selectedItem == menu10_52Item)
                {
                    statuses.Requesting10_52();
                }
                else if (selectedItem == menu10_53Item)
                {
                    statuses.Requesting10_53();
                }
            }
        }
예제 #8
0
        public void Script_Tick(object sender, EventArgs e)
        {
            // Load labs
            #region Lab Loading
            if (!MethLabsLoaded && !Game.IsLoading && Game.Player.CanControlCharacter)
            {
                try
                {
                    string labsFile = Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "mod_methoperation"), "methoperation_labs.xml");

                    if (!File.Exists(labsFile))
                    {
                        string backupLabsFile = Path.Combine("scripts", "methoperation_labs.xml");

                        Directory.CreateDirectory(Path.GetDirectoryName(labsFile));
                        File.Copy(backupLabsFile, labsFile);
                    }


                    if (File.Exists(labsFile))
                    {
                        MethLabs = XmlUtil.Deserialize <List <Lab> >(File.ReadAllText(labsFile));
                        foreach (Lab lab in MethLabs)
                        {
                            lab.CreateEntities();
                        }

                        ManagementBlip              = World.CreateBlip(Constants.MethLabLaptop);
                        ManagementBlip.Alpha        = 0;
                        ManagementBlip.Sprite       = BlipSprite.Laptop;
                        ManagementBlip.IsShortRange = true;
                        Function.Call(Hash.SET_BLIP_DISPLAY, ManagementBlip.Handle, 8);
                    }
                    else
                    {
                        UI.Notify($"~r~MethOperation labs file not found!");
                    }
                }
                catch (Exception ex)
                {
                    UI.Notify($"~r~MethOperation loading error: {ex.Message}");
                }

                MethLabsLoaded = true;
            }
            #endregion

            // process queued notifications
            if (!NotificationQueue.IsEmpty())
            {
                if (!Game.IsLoading)
                {
                    NotificationQueue.ProcessAll();
                }
            }

            // No need to go further if in a mission
            if (Mission.IsActive)
            {
                return;
            }

            // Update player position
            int gameTime = Game.GameTime;
            if (gameTime > NextUpdate)
            {
                NextUpdate     = gameTime + Constants.UpdateInterval;
                PlayerPosition = Game.Player.Character.Position;

                if (InsideMethLabIdx != -1)
                {
                    int interiorID = Function.Call <int>(Hash.GET_INTERIOR_AT_COORDS_WITH_TYPE, PlayerPosition.X, PlayerPosition.Y, PlayerPosition.Z, "bkr_biker_dlc_int_ware01");
                    if (interiorID != LabInteriorID)
                    {
                        LeftMethLab.Invoke(InsideMethLabIdx, LabExitReason.Teleport);
                        InsideMethLabIdx = -1;
                    }
                    else if (Game.Player.Character.Model.Hash != PlayerLabModel)
                    {
                        LeftMethLab.Invoke(InsideMethLabIdx, LabExitReason.CharacterChange);
                        InsideMethLabIdx = -1;
                    }
                }
            }

            // Draw markers & helptexts
            #region Drawing
            if (InsideMethLabIdx != -1)
            {
                // Handle NativeUI
                ManagementMenuPool.ProcessMenus();

                // Inside, draw interactable markers
                World.DrawMarker(MarkerType.VerticalCylinder, Constants.MethLabExit, Vector3.Zero, Vector3.Zero, Constants.MarkerScale, Constants.MarkerColor);
                World.DrawMarker(MarkerType.VerticalCylinder, Constants.MethLabLaptop, Vector3.Zero, Vector3.Zero, Constants.MarkerScale, Constants.MarkerColor);

                // Laptop screen
                if (LaptopRTID != -1)
                {
                    Function.Call(Hash.SET_TEXT_RENDER_ID, LaptopRTID);
                    Function.Call(Hash._SET_SCREEN_DRAW_POSITION, 73, 73);
                    Function.Call(Hash._SET_2D_LAYER, 4);
                    Function.Call(Hash._0xC6372ECD45D73BCD, true);
                    Function.Call((Hash)0x2BC54A8188768488, "prop_screen_biker_laptop", "prop_screen_biker_laptop_2", 0.5f, 0.5f, 1f, 1f, 0f, 255, 255, 255, 255);
                    Function.Call((Hash)0xE3A3DB414A373DAB);
                    Function.Call(Hash.SET_TEXT_RENDER_ID, 1);
                }

                if (PlayerPosition.DistanceTo(Constants.MethLabExit) <= Constants.MarkerInteractionDistance)
                {
                    CurrentInteractionType = InteractionType.ExitMethLab;
                    Util.DisplayHelpText($"Press {HelpTextKeys.Get(InteractionControl)} to leave the meth lab.");
                }
                else if (PlayerPosition.DistanceTo(Constants.MethLabLaptop) <= Constants.MarkerInteractionDistance)
                {
                    CurrentInteractionType = InteractionType.ManageMethLab;
                    Util.DisplayHelpText($"Press {HelpTextKeys.Get(InteractionControl)} to manage the meth lab.");
                }
                else
                {
                    ManagementMenuPool.CloseAllMenus();

                    if (IsLeaning)
                    {
                        CurrentInteractionType = InteractionType.CancelLean;
                        Util.DisplayHelpText($"Press {HelpTextKeys.Get(InteractionControl)} to stop leaning on the rail.");
                    }
                    else
                    {
                        if (Game.Player.Character.IsInArea(Constants.LeanAreaMin, Constants.LeanAreaMax))
                        {
                            CurrentInteractionType = InteractionType.Lean;
                            Util.DisplayHelpText($"Press {HelpTextKeys.Get(InteractionControl)} to lean on the rail.");
                        }
                    }
                }

                // Disable some controls inside the interior
                for (int i = 0; i < Constants.ControlsToDisable.Length; i++)
                {
                    Function.Call(Hash.DISABLE_CONTROL_ACTION, 2, Constants.ControlsToDisable[i], true);
                }
            }
            else
            {
                // Outside, draw lab markers
                for (int i = 0; i < MethLabs.Count; i++)
                {
                    DistanceToInteractable = PlayerPosition.DistanceTo(MethLabs[i].Position);

                    if (DistanceToInteractable <= Constants.MarkerDrawDistance)
                    {
                        World.DrawMarker(MarkerType.VerticalCylinder, MethLabs[i].Position, Vector3.Zero, Vector3.Zero, Constants.MarkerScale, Constants.MarkerColor);

                        if (DistanceToInteractable <= Constants.MarkerInteractionDistance)
                        {
                            InteractableLabIdx = i;

                            if (MethLabs[i].HasFlag(LabFlags.IsOwned))
                            {
                                CurrentInteractionType = InteractionType.EnterMethLab;
                                Util.DisplayHelpText($"Press {HelpTextKeys.Get(InteractionControl)} to enter the meth lab.");
                            }
                            else
                            {
                                CurrentInteractionType = InteractionType.BuyMethLab;
                                Util.DisplayHelpText($"Press {HelpTextKeys.Get(InteractionControl)} to buy the {MethLabs[i].Location} meth lab.~n~Price: ~g~${MethLabs[i].Price:N0}");
                            }

                            break;
                        }
                    }
                }
            }
            #endregion

            // Handle interactions
            #region Interaction Handling
            if (Game.IsControlJustPressed(2, (Control)InteractionControl))
            {
                int labIdx = InteractableLabIdx == -1 ? InsideMethLabIdx : InteractableLabIdx;
                if (labIdx == -1)
                {
                    return;
                }

                Character currentCharacter = Util.GetCharacterFromModel(Game.Player.Character.Model.Hash);
                if (currentCharacter == Character.Unknown)
                {
                    UI.Notify("Only Michael, Franklin and Trevor can interact with meth labs.");
                    return;
                }

                switch (CurrentInteractionType)
                {
                case InteractionType.BuyMethLab:
                    if (PlayerPosition.DistanceTo(MethLabs[labIdx].Position) > Constants.MarkerInteractionDistance)
                    {
                        return;
                    }

                    if (Game.Player.Money < MethLabs[labIdx].Price)
                    {
                        UI.Notify("You don't have enough money to buy this meth lab.");
                        return;
                    }

                    MethLabs[labIdx].Owner = currentCharacter;

                    MethLabs[labIdx].LastVisit = Util.GetGameDate();
                    MethLabs[labIdx].Flags     = LabFlags.None;
                    MethLabs[labIdx].AddFlag(LabFlags.IsOwned);

                    Game.Player.Money -= MethLabs[InteractableLabIdx].Price;
                    Save();

                    Util.NotifyWithPicture("LJT", $"{currentCharacter}, good call buying the {MethLabs[labIdx].Location} meth lab. Go inside and check the laptop to get started.", "CHAR_LJT", 1);
                    break;

                case InteractionType.EnterMethLab:
                    if (PlayerPosition.DistanceTo(MethLabs[labIdx].Position) > Constants.MarkerInteractionDistance)
                    {
                        return;
                    }

                    if (currentCharacter != MethLabs[labIdx].Owner)
                    {
                        UI.Notify($"Only the owner ({MethLabs[labIdx].Owner}) can enter this meth lab.");
                        return;
                    }

                    if (Game.MissionFlag)
                    {
                        UI.Notify("You can't enter meth labs while being in a mission.");
                        return;
                    }

                    if (Game.Player.WantedLevel > 0)
                    {
                        UI.Notify("You can't enter meth labs while being wanted by the police.");
                        return;
                    }

                    PlayerLabModel   = Game.Player.Character.Model.Hash;
                    InsideMethLabIdx = labIdx;
                    EnteredMethLab.Invoke(labIdx);

                    Game.Player.Character.Position = Constants.MethLabExit;
                    Game.Player.Character.Heading  = Constants.MethLabHeading;
                    Game.Player.Character.Weapons.Select(WeaponHash.Unarmed);
                    break;

                case InteractionType.ExitMethLab:
                    if (PlayerPosition.DistanceTo(Constants.MethLabExit) > Constants.MarkerInteractionDistance)
                    {
                        return;
                    }

                    Game.Player.Character.Position = MethLabs[labIdx].Position;

                    LeftMethLab.Invoke(labIdx, LabExitReason.Player);
                    InsideMethLabIdx = -1;
                    break;

                case InteractionType.ManageMethLab:
                    if (PlayerPosition.DistanceTo(Constants.MethLabLaptop) > Constants.MarkerInteractionDistance)
                    {
                        return;
                    }

                    ManagementMenuPool.RefreshIndex();
                    ManagementMain.Visible = true;
                    break;

                case InteractionType.Lean:
                    if (IsLeaning || !Game.Player.Character.IsInArea(Constants.LeanAreaMin, Constants.LeanAreaMax))
                    {
                        return;
                    }

                    Util.RequestAnimDict("anim@amb@yacht@rail@standing@male@variant_01@");
                    using (TaskSequence tseq = new TaskSequence())
                    {
                        Function.Call(Hash.TASK_GO_STRAIGHT_TO_COORD, 0, Constants.LeanPos.X, Constants.LeanPos.Y, Constants.LeanPos.Z, 1.0f, -1, Constants.LeanHeading, 0.0f);
                        tseq.AddTask.PlayAnimation("anim@amb@yacht@rail@standing@male@variant_01@", "enter");
                        tseq.AddTask.PlayAnimation("anim@amb@yacht@rail@standing@male@variant_01@", "base", 8.0f, -1, AnimationFlags.Loop);
                        tseq.Close();

                        Game.Player.Character.Task.PerformSequence(tseq);
                    }

                    IsLeaning = true;
                    break;

                case InteractionType.CancelLean:
                    if (!IsLeaning)
                    {
                        return;
                    }

                    Game.Player.Character.Task.PlayAnimation("anim@amb@yacht@rail@standing@male@variant_01@", "exit");
                    IsLeaning = false;
                    break;
                }
            }
            #endregion
        }
예제 #9
0
        public void Script_Tick(object sender, EventArgs e)
        {
            // Workaround for gun locker props not being created on mod init
            if (!GunLockersLoaded && !Game.IsLoading && Game.Player.CanControlCharacter)
            {
                GunLockersLoaded = true;
                Methods.LoadAddonWeapons();
                Methods.LoadGunLockers();
            }

            // Process script menus
            SPGLMenuPool.ProcessMenus();

            int gameTime = Game.GameTime;

            if (gameTime - LastHeartbeat >= Constants.HeartbeatInterval)
            {
                // Find the closest gun locker
                InteractableLockerGuid = Game.Player.Character.IsOnFoot ? Methods.FindInteractableGunLocker(Game.Player.Character.Position) : null;

                // Hide the menus if the player can't interact with a gun locker
                if (InteractableLockerGuid == null && SPGLMenuPool.IsAnyMenuOpen())
                {
                    SPGLMenuPool.CloseAllMenus();
                }

                LastHeartbeat = gameTime;
            }

            // Draw a helptext if the player can interact with a gun locker
            if (InteractableLockerGuid != null && !SPGLMenuPool.IsAnyMenuOpen())
            {
                Methods.DisplayHelpText($"Press {HelpTextKeys.Get(InteractionControl)} to interact with the Gun Locker.");
            }

            // Handle script controls
            if (Game.IsControlJustPressed(2, (Control)InteractionControl))
            {
                if (InteractableLockerGuid != null && GunLockers.ContainsKey(InteractableLockerGuid.Value))
                {
                    if (SPGLMenuPool.IsAnyMenuOpen())
                    {
                        SPGLMenuPool.CloseAllMenus();
                    }
                    else
                    {
                        SPGLMainMenu.RefreshIndex();
                        SPGLSellConfirmationMenu.RefreshIndex();
                        SPGLMainMenu.Visible = true;

                        // Update the weapons menu
                        SPGLWeaponsMenu.Clear();

                        for (int i = 0; i < Constants.MaxWeapons; i++)
                        {
                            string title = $"Empty Slot ({Methods.GetSlotWeaponType(i)})";

                            if (GunLockers[InteractableLockerGuid.Value].Weapons[i] != null)
                            {
                                title = Weapons.GetDisplayName(GunLockers[InteractableLockerGuid.Value].Weapons[i].Hash);
                            }

                            SPGLWeaponsMenu.AddItem(new UIMenuItem(title));
                        }

                        // Update the refund menu price
                        SPGLSellConfirmationMenu.MenuItems[0].SetRightLabel($"~HUD_COLOUR_GREENDARK~${GunLockers[ InteractableLockerGuid.Value ].RefundValue}");
                    }
                }
                else
                {
                    if (Game.Player.Character.IsOnFoot)
                    {
                        HoldingTime = gameTime;
                    }
                }
            }

            if (Game.IsControlJustReleased(2, (Control)InteractionControl))
            {
                HoldingTime = 0;
            }

            // Handle holding the interaction key to spawn a gun locker
            if (HoldingTime > 0)
            {
                int diff = gameTime - HoldingTime;
                if (diff >= 500 && InteractableLockerGuid == null)
                {
                    Methods.DrawText($"Buying a Gun Locker: ~b~{(diff * 100) / Constants.RequiredHoldingTime}% ~g~(${GunLockerPrice})", 0, 0.45f, Color.White, 0.05f, 0.05f);

                    if (diff >= Constants.RequiredHoldingTime)
                    {
                        HoldingTime = 0;

                        if (Game.Player.Money >= GunLockerPrice)
                        {
                            Game.Player.Money -= GunLockerPrice;

                            Locker newLocker = new Locker
                            {
                                RefundValue = GunLockerPrice,
                                Position    = Game.Player.Character.Position + Game.Player.Character.ForwardVector * Constants.PropDistance,
                                Rotation    = Game.Player.Character.Rotation
                            };

                            newLocker.CreateProp();
                            newLocker.Save();

                            GunLockers.Add(newLocker.ID, newLocker);
                        }
                        else
                        {
                            UI.Notify("~r~You can't afford a gun locker.");
                        }
                    }
                }
            }
        }
예제 #10
0
파일: Menu.cs 프로젝트: AviiNL/fiveliferp
 public void Close()
 {
     pool.CloseAllMenus();
 }
예제 #11
0
        public void AddVehicles(UIMenu menu)
        {
            //VEHICLES
            foreach (VehicleHash vehicle in allVehicles)
            {
                //Get Vehicle Name
                string vehiclename = API.GetDisplayNameFromVehicleModel((uint)vehicle);

                //Get Vehicle Class
                int    vehicleClass = API.GetVehicleClassFromName((uint)vehicle);
                string vehclass     = vehicleClass.ToString();

                //COMMERCIAL
                if (vehicleClass == 20)
                {
                    //Create Price
                    int Price = 4000;

                    //Create Menu Items
                    var newvehicle = new UIMenuItem(vehiclename);
                    newvehicle.SetRightLabel($"~g~${Price.ToString()}");
                    COMMERCIAL.AddItem(newvehicle);
                    COMMERCIAL.OnItemSelect += async(sender, item, index) =>
                    {
                        if (item == newvehicle)
                        {
                            if (Utilities.Constructors.playerMoney >= Price) //Check to ensure player has enough money
                            {
                                //Create Car
                                API.RequestModel((uint)vehicle);
                                while (!API.HasModelLoaded((uint)vehicle))
                                {
                                    await BaseScript.Delay(100);
                                }
                                int Rancherxl = API.CreateVehicle((uint)vehicle, CarSpawn.X, CarSpawn.Y, CarSpawn.Z, CarSpawnHeading, true, true);
                                API.TaskWarpPedIntoVehicle(Game.Player.Character.Handle, Rancherxl, -1);
                                _vehiclemenuPool.CloseAllMenus();

                                //Take Money
                                API.SetPedMoney(API.GetPlayerPed(-1), Utilities.Constructors.playerMoney - Price);
                            }
                            else
                            {
                                Screen.ShowNotification("~r~Not enough money");
                            }
                        }
                    };
                }

                //COMPACTS
                if (vehicleClass == 0)
                {
                    //Create Price
                    int Price = 2000;

                    //Create Menu Items
                    var newvehicle = new UIMenuItem(vehiclename);
                    newvehicle.SetRightLabel($"~g~${Price.ToString()}");
                    COMPACTS.AddItem(newvehicle);
                    COMPACTS.OnItemSelect += async(sender, item, index) =>
                    {
                        if (item == newvehicle)
                        {
                            if (Utilities.Constructors.playerMoney >= Price) //Check to ensure player has enough money
                            {
                                //Create Car
                                API.RequestModel((uint)vehicle);
                                while (!API.HasModelLoaded((uint)vehicle))
                                {
                                    await BaseScript.Delay(100);
                                }
                                int Rancherxl = API.CreateVehicle((uint)vehicle, CarSpawn.X, CarSpawn.Y, CarSpawn.Z, CarSpawnHeading, true, true);
                                API.TaskWarpPedIntoVehicle(Game.Player.Character.Handle, Rancherxl, -1);
                                _vehiclemenuPool.CloseAllMenus();

                                //Take Money
                                API.SetPedMoney(API.GetPlayerPed(-1), Utilities.Constructors.playerMoney - Price);
                            }
                            else
                            {
                                Screen.ShowNotification("~r~Not enough money");
                            }
                        }
                    };
                }

                //COUPES
                if (vehicleClass == 3)
                {
                    //Create Price
                    int Price = 1800;

                    //Create Menu Items
                    var newvehicle = new UIMenuItem(vehiclename);
                    newvehicle.SetRightLabel($"~g~${Price.ToString()}");
                    COUPES.AddItem(newvehicle);
                    COUPES.OnItemSelect += async(sender, item, index) =>
                    {
                        if (item == newvehicle)
                        {
                            if (Utilities.Constructors.playerMoney >= Price) //Check to ensure player has enough money
                            {
                                //Create Car
                                API.RequestModel((uint)vehicle);
                                while (!API.HasModelLoaded((uint)vehicle))
                                {
                                    await BaseScript.Delay(100);
                                }
                                int Rancherxl = API.CreateVehicle((uint)vehicle, CarSpawn.X, CarSpawn.Y, CarSpawn.Z, CarSpawnHeading, true, true);
                                API.TaskWarpPedIntoVehicle(Game.Player.Character.Handle, Rancherxl, -1);
                                _vehiclemenuPool.CloseAllMenus();

                                //Take Money
                                API.SetPedMoney(API.GetPlayerPed(-1), Utilities.Constructors.playerMoney - Price);
                            }
                            else
                            {
                                Screen.ShowNotification("~r~Not enough money");
                            }
                        }
                    };
                }

                //CYCLES
                if (vehicleClass == 13)
                {
                    //Create Price
                    int Price = 500;

                    //Create Menu Items
                    var newvehicle = new UIMenuItem(vehiclename);
                    newvehicle.SetRightLabel($"~g~${Price.ToString()}");
                    CYCLES.AddItem(newvehicle);
                    CYCLES.OnItemSelect += async(sender, item, index) =>
                    {
                        if (item == newvehicle)
                        {
                            if (Utilities.Constructors.playerMoney >= Price) //Check to ensure player has enough money
                            {
                                //Create Car
                                API.RequestModel((uint)vehicle);
                                while (!API.HasModelLoaded((uint)vehicle))
                                {
                                    await BaseScript.Delay(100);
                                }
                                int Rancherxl = API.CreateVehicle((uint)vehicle, CarSpawn.X, CarSpawn.Y, CarSpawn.Z, CarSpawnHeading, true, true);
                                API.TaskWarpPedIntoVehicle(Game.Player.Character.Handle, Rancherxl, -1);
                                _vehiclemenuPool.CloseAllMenus();

                                //Take Money
                                API.SetPedMoney(API.GetPlayerPed(-1), Utilities.Constructors.playerMoney - Price);
                            }
                            else
                            {
                                Screen.ShowNotification("~r~Not enough money");
                            }
                        }
                    };
                }

                //INDUSTRIAL
                if (vehicleClass == 10)
                {
                    //Create Price
                    int Price = 7500;

                    //Create Menu Items
                    var newvehicle = new UIMenuItem(vehiclename);
                    newvehicle.SetRightLabel($"~g~${Price.ToString()}");
                    INDUSTRIAL.AddItem(newvehicle);
                    INDUSTRIAL.OnItemSelect += async(sender, item, index) =>
                    {
                        if (item == newvehicle)
                        {
                            if (Utilities.Constructors.playerMoney >= Price) //Check to ensure player has enough money
                            {
                                //Create Car
                                API.RequestModel((uint)vehicle);
                                while (!API.HasModelLoaded((uint)vehicle))
                                {
                                    await BaseScript.Delay(100);
                                }
                                int Rancherxl = API.CreateVehicle((uint)vehicle, CarSpawn.X, CarSpawn.Y, CarSpawn.Z, CarSpawnHeading, true, true);
                                API.TaskWarpPedIntoVehicle(Game.Player.Character.Handle, Rancherxl, -1);
                                _vehiclemenuPool.CloseAllMenus();

                                //Take Money
                                API.SetPedMoney(API.GetPlayerPed(-1), Utilities.Constructors.playerMoney - Price);
                            }
                            else
                            {
                                Screen.ShowNotification("~r~Not enough money");
                            }
                        }
                    };
                }

                //MILITARY
                if (vehicleClass == 19)
                {
                    //Create Price
                    int Price = 15000;

                    //Create Menu Items
                    var newvehicle = new UIMenuItem(vehiclename);
                    newvehicle.SetRightLabel($"~g~${Price.ToString()}");
                    MILITARY.AddItem(newvehicle);
                    MILITARY.OnItemSelect += async(sender, item, index) =>
                    {
                        if (item == newvehicle)
                        {
                            if (Utilities.Constructors.playerMoney >= Price) //Check to ensure player has enough money
                            {
                                //Create Car
                                API.RequestModel((uint)vehicle);
                                while (!API.HasModelLoaded((uint)vehicle))
                                {
                                    await BaseScript.Delay(100);
                                }
                                int Rancherxl = API.CreateVehicle((uint)vehicle, CarSpawn.X, CarSpawn.Y, CarSpawn.Z, CarSpawnHeading, true, true);
                                API.TaskWarpPedIntoVehicle(Game.Player.Character.Handle, Rancherxl, -1);
                                _vehiclemenuPool.CloseAllMenus();

                                //Take Money
                                API.SetPedMoney(API.GetPlayerPed(-1), Utilities.Constructors.playerMoney - Price);
                            }
                            else
                            {
                                Screen.ShowNotification("~r~Not enough money");
                            }
                        }
                    };
                }

                //MOTORCYCLES
                if (vehicleClass == 8)
                {
                    //Create Price
                    int Price = 7500;

                    //Create Menu Items
                    var newvehicle = new UIMenuItem(vehiclename);
                    newvehicle.SetRightLabel($"~g~${Price.ToString()}");
                    MOTORCYCLES.AddItem(newvehicle);
                    MOTORCYCLES.OnItemSelect += async(sender, item, index) =>
                    {
                        if (item == newvehicle)
                        {
                            if (Utilities.Constructors.playerMoney >= Price) //Check to ensure player has enough money
                            {
                                //Create Car
                                API.RequestModel((uint)vehicle);
                                while (!API.HasModelLoaded((uint)vehicle))
                                {
                                    await BaseScript.Delay(100);
                                }
                                int Rancherxl = API.CreateVehicle((uint)vehicle, CarSpawn.X, CarSpawn.Y, CarSpawn.Z, CarSpawnHeading, true, true);
                                API.TaskWarpPedIntoVehicle(Game.Player.Character.Handle, Rancherxl, -1);
                                _vehiclemenuPool.CloseAllMenus();

                                //Take Money
                                API.SetPedMoney(API.GetPlayerPed(-1), Utilities.Constructors.playerMoney - Price);
                            }
                            else
                            {
                                Screen.ShowNotification("~r~Not enough money");
                            }
                        }
                    };
                }

                //MUSCLE
                if (vehicleClass == 4)
                {
                    //Create Price
                    int Price = 7500;

                    //Create Menu Items
                    var newvehicle = new UIMenuItem(vehiclename);
                    newvehicle.SetRightLabel($"~g~${Price.ToString()}");
                    MUSCLE.AddItem(newvehicle);
                    MUSCLE.OnItemSelect += async(sender, item, index) =>
                    {
                        if (item == newvehicle)
                        {
                            if (Utilities.Constructors.playerMoney >= Price) //Check to ensure player has enough money
                            {
                                //Create Car
                                API.RequestModel((uint)vehicle);
                                while (!API.HasModelLoaded((uint)vehicle))
                                {
                                    await BaseScript.Delay(100);
                                }
                                int Rancherxl = API.CreateVehicle((uint)vehicle, CarSpawn.X, CarSpawn.Y, CarSpawn.Z, CarSpawnHeading, true, true);
                                API.TaskWarpPedIntoVehicle(Game.Player.Character.Handle, Rancherxl, -1);
                                _vehiclemenuPool.CloseAllMenus();

                                //Take Money
                                API.SetPedMoney(API.GetPlayerPed(-1), Utilities.Constructors.playerMoney - Price);
                            }
                            else
                            {
                                Screen.ShowNotification("~r~Not enough money");
                            }
                        }
                    };
                }

                //OFFROAD
                if (vehicleClass == 9)
                {
                    //Create Price
                    int Price = 8000;

                    //Create Menu Items
                    var newvehicle = new UIMenuItem(vehiclename);
                    newvehicle.SetRightLabel($"~g~${Price.ToString()}");
                    OFFROAD.AddItem(newvehicle);
                    OFFROAD.OnItemSelect += async(sender, item, index) =>
                    {
                        if (item == newvehicle)
                        {
                            if (Utilities.Constructors.playerMoney >= Price) //Check to ensure player has enough money
                            {
                                //Create Car
                                API.RequestModel((uint)vehicle);
                                while (!API.HasModelLoaded((uint)vehicle))
                                {
                                    await BaseScript.Delay(100);
                                }
                                int Rancherxl = API.CreateVehicle((uint)vehicle, CarSpawn.X, CarSpawn.Y, CarSpawn.Z, CarSpawnHeading, true, true);
                                API.TaskWarpPedIntoVehicle(Game.Player.Character.Handle, Rancherxl, -1);
                                _vehiclemenuPool.CloseAllMenus();

                                //Take Money
                                API.SetPedMoney(API.GetPlayerPed(-1), Utilities.Constructors.playerMoney - Price);
                            }
                            else
                            {
                                Screen.ShowNotification("~r~Not enough money");
                            }
                        }
                    };
                }

                //SEDANS
                if (vehicleClass == 1)
                {
                    //Create Price
                    int Price = 5000;

                    //Create Menu Items
                    var newvehicle = new UIMenuItem(vehiclename);
                    newvehicle.SetRightLabel($"~g~${Price.ToString()}");
                    SEDANS.AddItem(newvehicle);
                    SEDANS.OnItemSelect += async(sender, item, index) =>
                    {
                        if (item == newvehicle)
                        {
                            if (Utilities.Constructors.playerMoney >= Price) //Check to ensure player has enough money
                            {
                                //Create Car
                                API.RequestModel((uint)vehicle);
                                while (!API.HasModelLoaded((uint)vehicle))
                                {
                                    await BaseScript.Delay(100);
                                }
                                int Rancherxl = API.CreateVehicle((uint)vehicle, CarSpawn.X, CarSpawn.Y, CarSpawn.Z, CarSpawnHeading, true, true);
                                API.TaskWarpPedIntoVehicle(Game.Player.Character.Handle, Rancherxl, -1);
                                _vehiclemenuPool.CloseAllMenus();

                                //Take Money
                                API.SetPedMoney(API.GetPlayerPed(-1), Utilities.Constructors.playerMoney - Price);
                            }
                            else
                            {
                                Screen.ShowNotification("~r~Not enough money");
                            }
                        }
                    };
                }

                //SERVICE
                if (vehicleClass == 17)
                {
                    //Create Price
                    int Price = 4000;

                    //Create Menu Items
                    var newvehicle = new UIMenuItem(vehiclename);
                    newvehicle.SetRightLabel($"~g~${Price.ToString()}");
                    SERVICE.AddItem(newvehicle);
                    SERVICE.OnItemSelect += async(sender, item, index) =>
                    {
                        if (item == newvehicle)
                        {
                            if (Utilities.Constructors.playerMoney >= Price) //Check to ensure player has enough money
                            {
                                //Create Car
                                API.RequestModel((uint)vehicle);
                                while (!API.HasModelLoaded((uint)vehicle))
                                {
                                    await BaseScript.Delay(100);
                                }
                                int Rancherxl = API.CreateVehicle((uint)vehicle, CarSpawn.X, CarSpawn.Y, CarSpawn.Z, CarSpawnHeading, true, true);
                                API.TaskWarpPedIntoVehicle(Game.Player.Character.Handle, Rancherxl, -1);
                                _vehiclemenuPool.CloseAllMenus();

                                //Take Money
                                API.SetPedMoney(API.GetPlayerPed(-1), Utilities.Constructors.playerMoney - Price);
                            }
                            else
                            {
                                Screen.ShowNotification("~r~Not enough money");
                            }
                        }
                    };
                }

                //SPORTS
                if (vehicleClass == 6)
                {
                    //Create Price
                    int Price = 9000;

                    //Create Menu Items
                    var newvehicle = new UIMenuItem(vehiclename);
                    newvehicle.SetRightLabel($"~g~${Price.ToString()}");
                    SPORTS.AddItem(newvehicle);
                    SPORTS.OnItemSelect += async(sender, item, index) =>
                    {
                        if (item == newvehicle)
                        {
                            if (Utilities.Constructors.playerMoney >= Price) //Check to ensure player has enough money
                            {
                                //Create Car
                                API.RequestModel((uint)vehicle);
                                while (!API.HasModelLoaded((uint)vehicle))
                                {
                                    await BaseScript.Delay(100);
                                }
                                int Rancherxl = API.CreateVehicle((uint)vehicle, CarSpawn.X, CarSpawn.Y, CarSpawn.Z, CarSpawnHeading, true, true);
                                API.TaskWarpPedIntoVehicle(Game.Player.Character.Handle, Rancherxl, -1);
                                _vehiclemenuPool.CloseAllMenus();

                                //Take Money
                                API.SetPedMoney(API.GetPlayerPed(-1), Utilities.Constructors.playerMoney - Price);
                            }
                            else
                            {
                                Screen.ShowNotification("~r~Not enough money");
                            }
                        }
                    };
                }

                //SPORTS CLASSICS
                if (vehicleClass == 5)
                {
                    //Create Price
                    int Price = 15000;

                    //Create Menu Items
                    var newvehicle = new UIMenuItem(vehiclename);
                    newvehicle.SetRightLabel($"~g~${Price.ToString()}");
                    SPORTSCLASSICS.AddItem(newvehicle);
                    SPORTSCLASSICS.OnItemSelect += async(sender, item, index) =>
                    {
                        if (item == newvehicle)
                        {
                            if (Utilities.Constructors.playerMoney >= Price) //Check to ensure player has enough money
                            {
                                //Create Car
                                API.RequestModel((uint)vehicle);
                                while (!API.HasModelLoaded((uint)vehicle))
                                {
                                    await BaseScript.Delay(100);
                                }
                                int Rancherxl = API.CreateVehicle((uint)vehicle, CarSpawn.X, CarSpawn.Y, CarSpawn.Z, CarSpawnHeading, true, true);
                                API.TaskWarpPedIntoVehicle(Game.Player.Character.Handle, Rancherxl, -1);
                                _vehiclemenuPool.CloseAllMenus();

                                //Take Money
                                API.SetPedMoney(API.GetPlayerPed(-1), Utilities.Constructors.playerMoney - Price);
                            }
                            else
                            {
                                Screen.ShowNotification("~r~Not enough money");
                            }
                        }
                    };
                }

                //SUPER
                if (vehicleClass == 7)
                {
                    //Create Price
                    int Price = 17500;

                    //Create Menu Items
                    var newvehicle = new UIMenuItem(vehiclename);
                    newvehicle.SetRightLabel($"~g~${Price.ToString()}");
                    SUPER.AddItem(newvehicle);
                    SUPER.OnItemSelect += async(sender, item, index) =>
                    {
                        if (item == newvehicle)
                        {
                            if (Utilities.Constructors.playerMoney >= Price) //Check to ensure player has enough money
                            {
                                //Create Car
                                API.RequestModel((uint)vehicle);
                                while (!API.HasModelLoaded((uint)vehicle))
                                {
                                    await BaseScript.Delay(100);
                                }
                                int Rancherxl = API.CreateVehicle((uint)vehicle, CarSpawn.X, CarSpawn.Y, CarSpawn.Z, CarSpawnHeading, true, true);
                                API.TaskWarpPedIntoVehicle(Game.Player.Character.Handle, Rancherxl, -1);
                                _vehiclemenuPool.CloseAllMenus();

                                //Take Money
                                API.SetPedMoney(API.GetPlayerPed(-1), Utilities.Constructors.playerMoney - Price);
                            }
                            else
                            {
                                Screen.ShowNotification("~r~Not enough money");
                            }
                        }
                    };
                }

                //SUV
                if (vehicleClass == 2)
                {
                    //Create Price
                    int Price = 10000;

                    //Create Menu Items
                    var newvehicle = new UIMenuItem(vehiclename);
                    newvehicle.SetRightLabel($"~g~${Price.ToString()}");
                    SUV.AddItem(newvehicle);
                    SUV.OnItemSelect += async(sender, item, index) =>
                    {
                        if (item == newvehicle)
                        {
                            if (Utilities.Constructors.playerMoney >= Price) //Check to ensure player has enough money
                            {
                                //Create Car
                                API.RequestModel((uint)vehicle);
                                while (!API.HasModelLoaded((uint)vehicle))
                                {
                                    await BaseScript.Delay(100);
                                }
                                int Rancherxl = API.CreateVehicle((uint)vehicle, CarSpawn.X, CarSpawn.Y, CarSpawn.Z, CarSpawnHeading, true, true);
                                API.TaskWarpPedIntoVehicle(Game.Player.Character.Handle, Rancherxl, -1);
                                _vehiclemenuPool.CloseAllMenus();

                                //Take Money
                                API.SetPedMoney(API.GetPlayerPed(-1), Utilities.Constructors.playerMoney - Price);
                            }
                            else
                            {
                                Screen.ShowNotification("~r~Not enough money");
                            }
                        }
                    };
                }

                //UTILITY
                if (vehicleClass == 11)
                {
                    //Create Price
                    int Price = 3500;

                    //Create Menu Items
                    var newvehicle = new UIMenuItem(vehiclename);
                    newvehicle.SetRightLabel($"~g~${Price.ToString()}");
                    UTILITY.AddItem(newvehicle);
                    UTILITY.OnItemSelect += async(sender, item, index) =>
                    {
                        if (item == newvehicle)
                        {
                            if (Utilities.Constructors.playerMoney >= Price) //Check to ensure player has enough money
                            {
                                //Create Car
                                API.RequestModel((uint)vehicle);
                                while (!API.HasModelLoaded((uint)vehicle))
                                {
                                    await BaseScript.Delay(100);
                                }
                                int Rancherxl = API.CreateVehicle((uint)vehicle, CarSpawn.X, CarSpawn.Y, CarSpawn.Z, CarSpawnHeading, true, true);
                                API.TaskWarpPedIntoVehicle(Game.Player.Character.Handle, Rancherxl, -1);
                                _vehiclemenuPool.CloseAllMenus();

                                //Take Money
                                API.SetPedMoney(API.GetPlayerPed(-1), Utilities.Constructors.playerMoney - Price);
                            }
                            else
                            {
                                Screen.ShowNotification("~r~Not enough money");
                            }
                        }
                    };
                }

                //VANS
                if (vehicleClass == 12)
                {
                    //Create Price
                    int Price = 4000;

                    //Create Menu Items
                    var newvehicle = new UIMenuItem(vehiclename);
                    newvehicle.SetRightLabel($"~g~${Price.ToString()}");
                    VANS.AddItem(newvehicle);
                    VANS.OnItemSelect += async(sender, item, index) =>
                    {
                        if (item == newvehicle)
                        {
                            if (Utilities.Constructors.playerMoney >= Price) //Check to ensure player has enough money
                            {
                                //Create Car
                                API.RequestModel((uint)vehicle);
                                while (!API.HasModelLoaded((uint)vehicle))
                                {
                                    await BaseScript.Delay(100);
                                }
                                int Rancherxl = API.CreateVehicle((uint)vehicle, CarSpawn.X, CarSpawn.Y, CarSpawn.Z, CarSpawnHeading, true, true);
                                API.TaskWarpPedIntoVehicle(Game.Player.Character.Handle, Rancherxl, -1);
                                _vehiclemenuPool.CloseAllMenus();

                                //Take Money
                                API.SetPedMoney(API.GetPlayerPed(-1), Utilities.Constructors.playerMoney - Price);
                            }
                            else
                            {
                                Screen.ShowNotification("~r~Not enough money");
                            }
                        }
                    };
                }
            }
        }
예제 #12
0
        void OnTick(object sender, EventArgs e)                                                 // This is where most of your script goes
        {
            if (Function.Call <bool>(Hash._0x557E43C447E700A8, Game.GenerateHash("ptfx_menu"))) // _HAS_CHEAT_STRING_JUST_BEEN_ENTERED
            {
                _menuPool.OpenCloseLastMenu();
                Wait(150);
            }

            if (Function.Call <bool>(Hash._0x557E43C447E700A8, Game.GenerateHash("ptfx_dump"))) // _HAS_CHEAT_STRING_JUST_BEEN_ENTERED
            {
                PTFXDumpToXML.ConvertToXML();
                UI.Notify("PTFX Dump Done! Restart script with the INS key.");
                Wait(150);
            }

            if (PtfxPlayerComm.IsEventTriggered())
            {
                _menuPool.OpenCloseLastMenu();

                PtfxPlayerComm.BlockScriptCommunicatorModMenu();
                PtfxPlayerComm.ResetEvent();
                Wait(300);
            }

            if (!allowMenuDraw)
            {
                //AdjustMenu();

                if (doSearch)
                {
                    SetupSearchMenu(); doSearch = false;
                }
                if (rebuildFavourites)
                {
                    FavouritesMenu.ResetIndexPosition();
                    FavouritesMenu.SelectedItem = null;
                    FavouritesMenu.UIMenuItemList.Clear();
                    Re_BuildFavouritesMenu();
                    FavouritesMenu.SetIndexPosition(favLastIndex <= FavouritesMenu.UIMenuItemList.Count - 1 ? favLastIndex : FavouritesMenu.UIMenuItemList.Count - 1);
                    rebuildFavourites = false;
                }

                allowMenuDraw = true;
            }
            if (allowMenuDraw)
            {
                _menuPool.ProcessMenus();

                if (JustPressedMenuControls())
                {
                    if (_menuPool.IsAnyMenuOpen())
                    {
                        _menuPool.CloseAllMenus();
                    }
                    else
                    {
                        if (!SCHelperExists)
                        {
                            _menuPool.LastUsedMenu.IsVisible = !_menuPool.LastUsedMenu.IsVisible;
                        }
                    }

                    InputTimer = DateTime.Now.AddMilliseconds(300);
                }

                if (_menuPool.LastUsedMenu.IsVisible)
                {
                    PtfxPlayerComm.BlockScriptCommunicatorModMenu();
                }
                else
                {
                    if (PtfxPlayerComm.ScriptCommunicatorMenuIsBlocked())
                    {
                        //Wait(300);
                        PtfxPlayerComm.UnblockScriptCommunicatorModMenu();
                    }
                }
            }
        }
예제 #13
0
    public void AddMenuCook(UIMenu menu)
    {
        var newitem = new UIMenuItem("Cook!", "Cook the dish with the appropiate ingredients and ketchup.");

        newitem.SetLeftBadge(UIMenuItem.BadgeStyle.Star);
        newitem.SetRightBadge(UIMenuItem.BadgeStyle.Tick);
        menu.AddItem(newitem);
        menu.OnItemSelect += (sender, item, index) =>
        {
            if (item == newitem)
            {
                string output = ketchup ? "You have ordered ~b~{0}~w~ ~r~with~w~ ketchup." : "You have ordered ~b~{0}~w~ ~r~without~w~ ketchup.";
                Screen.ShowSubtitle(String.Format(output, dish));
            }
        };

        menu.OnIndexChange += (sender, index) =>
        {
            if (sender.MenuItems[index] == newitem)
            {
                newitem.SetLeftBadge(UIMenuItem.BadgeStyle.None);
            }
        };

        var colorItem = new UIMenuItem("UIMenuItem with Colors", "~b~Look!!~r~I can be colored ~y~too!!~w~", Color.FromArgb(150, 185, 230, 185), Color.FromArgb(170, 174, 219, 242));

        menu.AddItem(colorItem);

        var foods = new List <dynamic>
        {
            "Banana",
            "Apple",
            "Pizza",
            "Quartilicious",
            0xF00D,             // Dynamic!
        };

        var BlankItem = new UIMenuSeparatorItem();

        menu.AddItem(BlankItem);

        var colorListItem = new UIMenuListItem("Colored ListItem.. Really?", foods, 0, "~b~Look!!~r~I can be colored ~y~too!!~w~", Color.FromArgb(150, 185, 230, 185), Color.FromArgb(170, 174, 219, 242));

        menu.AddItem(colorListItem);

        var Slider = new UIMenuSliderItem("Slider Item", "Cool!", true);         // by default max is 100 and multipler 5 = 20 steps.

        menu.AddItem(Slider);

        var SliderProgress = new UIMenuSliderProgressItem("Slider Progress Item", 10, 0);

        menu.AddItem(SliderProgress);

        var Progress = new UIMenuProgressItem("Progress Item", "descriptiom", 10, 0, true);

        menu.AddItem(Progress);

        var listPanelItem1 = new UIMenuListItem("Change Color", new List <object> {
            "Example", "example2"
        }, 0);
        var ColorPanel = new UIMenuColorPanel("Color Panel Example", UIMenuColorPanel.ColorPanelType.Hair);

        // you can choose between hair palette or makeup palette
        menu.AddItem(listPanelItem1);
        listPanelItem1.AddPanel(ColorPanel);

        var listPanelItem2 = new UIMenuListItem("Change Percentage", new List <object> {
            "Example", "example2"
        }, 0);
        var PercentagePanel = new UIMenuPercentagePanel("Percentage Panel Example", "0%", "100%");

        // You can change every text in this Panel
        menu.AddItem(listPanelItem2);
        listPanelItem2.AddPanel(PercentagePanel);

        var listPanelItem3 = new UIMenuListItem("Change Grid Position", new List <object> {
            "Example", "example2"
        }, 0);
        var GridPanel = new UIMenuGridPanel("Up", "Left", "Right", "Down", new System.Drawing.PointF(.5f, .5f));

        // you can choose the text in every position and where to place the starting position of the cirlce
        // the other 2 grids panel available are not listed as they work the same way but in only 2 direction (horizontally or vertically)
        // and to use them you must stream the stream folder provided with NativeUI project
        menu.AddItem(listPanelItem3);
        listPanelItem3.AddPanel(GridPanel);

        var listPanelItem4 = new UIMenuListItem("Look at Statistics", new List <object> {
            "Example", "example2"
        }, 0);
        var statistics = new UIMenuStatisticsPanel();

        statistics.AddStatistics("Look at this!");
        statistics.AddStatistics("I'm a statistic too!");
        statistics.AddStatistics("Am i not?!");
        //you can add as menu statistics you want
        statistics.SetPercentage(0, 10f);
        statistics.SetPercentage(1, 50f);
        statistics.SetPercentage(2, 100f);
        //and you can get / set their percentage
        menu.AddItem(listPanelItem4);
        listPanelItem4.AddPanel(statistics);

        UIMenuItem PauseMenu = new UIMenuItem("Open custom pauseMenu");

        menu.AddItem(PauseMenu);
        PauseMenu.Activated += (_submenu, item) =>
        {
            _menuPool.CloseAllMenus();
            OpenCustomPauseMenu();
        };

        // THERE ARE NO EVENTS FOR PANELS.. WHEN YOU CHANGE WHAT IS CHANGABLE THE LISTITEM WILL DO WHATEVER YOU TELL HIM TO DO

        menu.OnListChange += (sender, item, index) =>
        {
            if (item == listPanelItem1)
            {
                Screen.ShowNotification("Selected color " + ((item.Panels[0] as UIMenuColorPanel).CurrentSelection + 1) + "...");
                item.Description = "Selected color " + ((item.Panels[0] as UIMenuColorPanel).CurrentSelection + 1) + "...";
                item.Parent.UpdateDescription();                 // this is neat.. this will update the description of the item without refresh index.. try it by changing color
            }
            else if (item == listPanelItem2)
            {
                Screen.ShowSubtitle("Percentage = " + (item.Panels[0] as UIMenuPercentagePanel).Percentage + "...");
            }
            else if (item == listPanelItem3)
            {
                Screen.ShowSubtitle("GridPosition = " + (item.Panels[0] as UIMenuGridPanel).CirclePosition + "...");
            }
        };
    }