[C#][NativeUI] How to create a mod menu using NativeUI(Part 2)
Yes, I have a lot of time on my hands
Hello guys, this is the part two of the mod menu creation series, I was bored and want to do it now
Need to follow the last tutorial to keep up.
In the last one, we left off at a simple weapon selector and a reset wanted level. First thing I want to do is re-organize some stuff, like put the Reset Wanted Level into its own Player submenu and the Weapon Selector in its own Weapon submenu. Lets start by adding the UIMenu variables:
Now, lets edit the Setup function a bit:
I also want to edit one more thing, I want to add different functions to setup the functions, like this:
Now, let's cleanup some code, like we did for the weapon selector, and put everything in one function(for the reset wanted level, of course):
I removed the other onMainMenuItemSelect code, since it was useless now. This is what the code looks like now, and I would say it is very more readable. We also need to change one line of code in our Weapon Selector:
Also we should remove the call to WeaponSelectorMenu() in the constructor, and instead put the SetupPlayerWeapons in the setup:
Everything is good now! Lets now make a new Vehicle menu, and add a Vehicle Selector(like the Weapon selector) and also a way to spawn by name. Lets start with the menu:
And lets edit our Setup function:
Lets now make a SetupVehicleFunction method:
Awesome! Now here we will put all our Vehicle functions. Lets start by the Vehicle Selector:
NOTE: I messed up, and put weaponsMenu in the AddSubMenu function. Make sure to put vehiclesMenu!!!!!
It is like the weapon selector, so i skipped most of it. But now, lets spawn our selecter vehicle and warp our player into it:
Lets put this function in our SetupVehicleFunction, and lets test this:
As you can see, this works! Next up, we should give the player the ability to spawn cars by their model name, like t20 or osiris. This is pretty easy to do, and so we will do it. Lets start by making a new function and an item:
Lets work on our functionality. To get the input, we will use Game.GetUserInput, which returns a string we input. The input box is like a cheat code input, and so it makes it very easy:
Here, we get the input, and get a model out of it. Then, we request the model, so it is loaded in our game. Now, one thing we NEED to do, is check if the model actually exists! People could input string like asdasfgsgedfygse and if he used that, the mod would crash! So, lets add that check:
Simple to understand, lets add the spawning now:
This is it for that piece of code, so now lets add this function to our SetupVehicleFunctions function:
This code works ingame, so now we can move on, to something more. Let's add one last thing to wrap up this part of the tutorial, and that of course is get all weapons. That is fairly very very easy. Lets make a new function like always:
And now lets add our button and our functionality:
Simple enough, lets put the function in our SetupWeaponFunctions function, and we will be good to go:
Well, that wraps up our second part of the tutorial. We got a lot done here! In the next one, we will add more features, duh, but we will also add a Remove All Weapons feature. That will be the first one where we need to use natives, and that is why i didnt do it in this tutorial. But until then, bye!
Thanks so very much for this, I'll be trying this out when I get back from vacation, what does the menu look like in game?
Oh cool, I like that
@GTAVModder4Life i want to say THANK YOU again for made this happen.
Your tutorials helps us a lot!!!
Awesome dude! @TobsiCred
@GTAVModder4Life One of the most influencing tutorials I have read/studied. Very nicely explained and in detailed steps that one doesnt even need FAQs. Thank you so much again.
Seems I was incorrect in my past post about an update maybe causing issues. Having set my gtav to high priority in task manager fixed my issue. Also love this tutorial