[C#][NativeUI] How to create a mod menu using NativeUI(Part 3)
Hello guys, this is the part 3 of how to create a mod menu series.
Need to follow the last two tutorials.
Without further ado, lets start off with a Remove All Weapons feature, as promised. Keep in mind though, we will be using natives. Like every other function, lets create a new method for that function, which is RemoveAllWeapons():
Lets now create an Item, and an array to hold all of the weapons in the game:
Now we will add the item to the menu, and create the OnItemSelect event:
Now, we will check if the player has a certain weapon, like this, in a foreach loop of course, and call a Remove function:
Now, if we put the function in SetupWeaponFunctions():
And test it, there is a little bit of a bug:
As you can see, we dont have an unarmed weapon, whatever you call it, and you cant punch people. So, we need to add an if statement, if the weapon hash isnt unarmed, like this:
That fixes this bug, and so removing all weapons feature is complete. Next thing thing that is ESSENTIAL for a mod menu, is a vehicle color chooser, which is really like all of the selectors. First off, we will make a submenu, a list for both primary and secondary colors, and also put them in an array:
And now lets do the for loop to put everything in the lists:
Now, instead of doing a button, we will do a OnListChange. which gets called every time you select a new item in the list. I think that is an awesome way to do this, so lets first do it for the primarycolor:
Since this works, we will copy this code to make it for secondary as well:
And also, dont forget to add the function to the SetupVehicleFunctions() list!
Lets now work on a God Mode for the Player, which is quite easy. Remember, I am making a tutorial for a fully fledged Mod Menu, so this is important This is the whole and easy code for god mode:
We have a bool, which we put outside of the godModeOn function. We make the button, and do everything, and in the OnItemSelect event, we check if the button pressed is our button. If it is, we toggle between godModeOn. If it is true, we set our invincibility to true, and set the text. If false, we do the opposite. Simple enough, right?
The final thing we will do now, is a Never Wanted button, with the same principal as above:
For this one, we will utilize the tick function, always setting our wanted level to 0, if the bool is true. But first, we have to toggle it!
And now, in our onTick, we make a simple if statement:
Done! We will keep doing new features for our mod menu, and keep modding it until we have a good menu setup. Until then, bye!
Nice Tutorial like every of you tutorials maybe you come in skype online than i can explain it to you what i mean with Ceate PickUps !
@Eugenius of course, add me:
When i enable the God Mode option in my menu it also enables Never Wanted. Any idea how to fix this?
@AHK1221 To remove all weapons simply call Game.Player.Character.Weapons.RemoveAll();
@MayhemGaming Show your code.
are you going to do a part 4?
Doesnt work heres a screenshot of that part of my code:
@PrepareForMayhem Try this instead:
VehicleColor chosenColor = listItem.Items[newIndex];
IndexToItem is obsolete: https://github.com/Guad/NativeUI/blob/master/NativeUI/Items/UIMenuListItem.cs#L107
@Jitnaught still doesnt work.
@PrepareForMayhem I'm assuming you're getting an error related to casting. Try adding
(VehicleColor)in front of
@Jitnaught That worked thank you!
@Jitnaught Never mind it shows up theres no errors in the code but then when I try to change color it shows this:
@PrepareForMayhem That error doesn't tell me much. Try compiling the mod in Debug and copy the .dll and .pdb files to the scripts folder, then try the mod again and it should hopefully give you a better error message.
If you copy those files you can also debug the mod from Visual Studio. Just go to
Debug > Attach to Processin Visual studio and select GTA5, then Visual Studio will show you where the error is, and you can set breakpoints. I've heard that newer versions of GTA V don't like this though, and that you need to run RPH to be able to do this now.
@Jitnaught Do you have discord I find it easier to talk to people and send stuff on that.
But Whats RPH?
Yes I have Discord. My username is Jitnaught#4171. You can also join the 5Mods Discord server, which I am on: https://forums.gta5-mods.com/topic/11384/pc-singleplayer-only-discord-server-for-gta5-mods-com-join-us
RPH is RAGE Plugin Hook: http://ragepluginhook.net/Downloads.aspx?Category=1