Log in to reply
 

[C#][NativeUI] How to create a mod menu using NativeUI(Part 2)



  • Yes, I have a lot of time on my handsxD

    Hello guys, this is the part two of the mod menu creation series, I was bored and want to do it now :P

    Requirements:
    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:
    alt text
    Now, lets edit the Setup function a bit:
    alt text
    I also want to edit one more thing, I want to add different functions to setup the functions, like this:
    alt text
    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):
    alt text
    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:
    alt text
    Also we should remove the call to WeaponSelectorMenu() in the constructor, and instead put the SetupPlayerWeapons in the setup:
    alt text
    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:
    alt text
    And lets edit our Setup function:
    alt text
    Lets now make a SetupVehicleFunction method:
    alt text
    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!!!!!
    alt text
    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:
    alt text
    Lets put this function in our SetupVehicleFunction, and lets test this:
    alt text
    ![alt text](http://i.imgur.com/3Bl7UFz.png
    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:
    alt text
    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:
    alt text
    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:
    alt text
    Simple to understand, lets add the spawning now:
    alt text
    This is it for that piece of code, so now lets add this function to our SetupVehicleFunctions function:
    alt text
    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:
    alt text
    And now lets add our button and our functionality:
    alt text
    Simple enough, lets put the function in our SetupWeaponFunctions function, and we will be good to go:
    alt text
    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?



  • @Frazzlee looks like in eugenius&my mod NativeUiMenu just like the original ingame menus
    0_1470610873650_NativeUiMenu.jpg



  • Oh cool, I like that



  • @GTAVModder4Life i want to say THANK YOU again for made this happen.
    Your tutorials helps us a lot!!!

    0_1470664859815_Vehice Spawn Menu Imgur.jpg



  • 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 :)


Log in to reply
 

Looks like your connection to GTA5-Mods.com Forums was lost, please wait while we try to reconnect.