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!



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



  • @AHK1221 said in [C#][NativeUI] How to create a mod menu using NativeUI(Part 2):

    Game.GetUserInput

    hey i want to get intiger type values from user and want to use it in my script then what should i do



  • @harshil You can get the string from GetUserInput and then parse it into an integar by using int.TryParse or int.Parse.



  • @AHK1221 ok but if user add number as sting and i convert it into intiger then is it posible that the number is chenged because of it's ASCI value or somthing else



  • @harshil It shouldn't be. Whenever I've tried it it worked fine.



  • @AHK1221 ok thank you



  • Thanks this is very indept and it all still works as of August 29th 2019 but I was wondering if you were going to make more and if you did please link.



  • This post is deleted!

Log in to reply
 

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