Mod Menu Selecting More Options At Once! help!
-
So this is my first time attempting to code a mod menu for gta 5 and all the features so far are working great but there is one problem. When using the Player menu, say i select god mode it will enable god mode but it will also enable the option underneath it which in my case is Never wanted.
Here is my code:
public class Class1 : Script
{
MenuPool modMenuPool;
UIMenu mainMenu;UIMenu playerMenu; UIMenu vehicleMenu; bool godModeon = false; bool neverWantedlevelOn = false; Ped gamePed = Game.Player.Character; public Class1() { Setup(); Tick += onTick; KeyDown += OnKeyDown; } void Setup() { modMenuPool = new MenuPool(); mainMenu = new UIMenu("Mayhems Menu", "Main Menu"); modMenuPool.Add(mainMenu); playerMenu = modMenuPool.AddSubMenu(mainMenu, "Player"); vehicleMenu = modMenuPool.AddSubMenu(mainMenu, "Vehicle Spawner"); SetupPlayerFunctions(); SetupVehicleFunctions(); } void SetupPlayerFunctions() { godMode(); NeverWanted(); Money(); } void SetupVehicleFunctions() { SpawnVehicle(); SpawnVehicleName(); } void Money() { UIMenuItem giveMoney = new UIMenuItem("Give $10 mil"); playerMenu.AddItem(giveMoney); playerMenu.OnItemSelect += (sender, item, index) => { Game.Player.Money = Game.Player.Money + 10000000; }; } void NeverWanted() { UIMenuItem neverWanted = new UIMenuItem("Never Wanted: " + neverWantedlevelOn.ToString()); playerMenu.AddItem(neverWanted); playerMenu.OnItemSelect += (sender, item, index) => { neverWantedlevelOn = !neverWantedlevelOn; if (neverWantedlevelOn) { neverWanted.Text = "Never Wanted: " + true.ToString(); } else { neverWanted.Text = "Never Wanted: " + false.ToString(); } }; } void godMode() { UIMenuItem godMode = new UIMenuItem("God Mode: " + godModeon.ToString()); playerMenu.AddItem(godMode); playerMenu.OnItemSelect += (sender, item, index) => { godModeon = !godModeon; if (item == godMode) { if (godModeon) { Game.Player.IsInvincible = true; gamePed.IsInvincible = true; godMode.Text = "God Mode: " + true.ToString(); } else { Game.Player.IsInvincible = false; gamePed.IsInvincible = false; godMode.Text = "God Mode: " + false.ToString(); } } }; } void SpawnVehicleName() { UIMenuItem vehicleSpawnItem = new UIMenuItem("Spawn Vehicle By Name"); vehicleMenu.AddItem(vehicleSpawnItem); vehicleMenu.OnItemSelect += (sender, item, index) => { if (item == vehicleSpawnItem) { string modelName = Game.GetUserInput(50); Model model = new Model(modelName); model.Request(); if (model.IsValid) { Vehicle veh = World.CreateVehicle(model, gamePed.Position, gamePed.Heading); veh.PlaceOnGround(); gamePed.Task.WarpIntoVehicle(veh, VehicleSeat.Driver); UI.ShowSubtitle("~b~" + modelName + " Spawned~b~", 2000); } else { UI.ShowSubtitle("~r~" + modelName + " Is Not A Vehicle~r~", 2000); } } }; } void SpawnVehicle() { List<dynamic> listOfVehicles = new List<dynamic>(); VehicleHash[] allVehicleHashes = (VehicleHash[])Enum.GetValues(typeof(VehicleHash)); for (int i = 0; i < allVehicleHashes.Length; i++) { listOfVehicles.Add(allVehicleHashes[i]); } UIMenuListItem list = new UIMenuListItem("Vehicles: ", listOfVehicles, 0); vehicleMenu.AddItem(list); UIMenuItem getVehicle = new UIMenuItem("Spawn Vehicle"); vehicleMenu.AddItem(getVehicle); vehicleMenu.OnItemSelect += (sender, item, index) => { if (item == getVehicle) { int listIndex = list.Index; VehicleHash hash = allVehicleHashes[listIndex]; Vehicle veh = World.CreateVehicle(hash, gamePed.Position, gamePed.Heading); veh.PlaceOnGround(); gamePed.Task.WarpIntoVehicle(veh, VehicleSeat.Driver); UI.ShowSubtitle("~b~" + hash + " Spawned~b~", 2000); } }; } void onTick(object sender, EventArgs e) { if (modMenuPool != null) modMenuPool.ProcessMenus(); if(neverWantedlevelOn) { Game.Player.WantedLevel = 0; } } void OnKeyDown(object sender, KeyEventArgs e) { if(e.KeyCode == Keys.F10 && !modMenuPool.IsAnyMenuOpen()) { mainMenu.Visible = !mainMenu.Visible; } } }
-
In NeverWanted(), you need to place some of your code within this if statement:
if (item == neverWanted)
Since you haven't, your neverWanted code is executed whenever you select any item in the playerMenu menu.
In godMode(), you almost have it. Just move the line
godModeon = !godModeon;
to inside the "if (item == godMode)" statement. How it is now, your godModeon bool will always switch between true and false when you select any item.
-
@stillhere Thank You
-
@stillhere One quick question, how do you disable the mouse for a NativeUI menu?
-
Probably setting the MouseControlsEnabled field to false in your UIMenu instance.
-
@ikt how would you right it though?
i've tried UIMenu.MouseControlsEnabled = false;
but it doesn't work
-
@MayhemGaming
That should work. Try placing like somainMenu = new UIMenu("Mayhems Menu", "Main Menu"); mainMenu.MouseControlsEnabled = false;
I can't be bothered to check the NativeUI source right now but that should work. If it doesn't then disable it in your OnTick method.