Log in to reply

Need help with .ini file

  • i'm using the nativeUI Template and wanted to create a ini file to open the menu but how? these were some lines that might be some use:

    //Here we will add the code to use a .INI file for your menu open key
    ScriptSettings config;
    Keys OpenMenu;

    //We will now call from the .INI file for our controls
    config = ScriptSettings.Load("scripts\settings.ini");
    OpenMenu = config.GetValue<Keys>("Options", "OpenMenu", Keys.F7); //The F7 key will be set my default, but the user can change the key

  • Personally I prefer to use Settings instead of ScriptSettings. With Settings you don't specify a path, it generates one automatically for you based on your mod's name (so if your mod is named BestMod in Visual Studio, the INI should be named BestMod.ini).

    Keys openMenuKey;
    public Test()
    	openMenuKey = Settings.GetValue("Options", "OpenMenuKey", Keys.F7); //F7 = default
    	KeyDown += Test_OnKeyDown;
    private void Test_OnKeyDown(object sender, KeyEventArgs e)
    	if (e.KeyCode == openMenuKey)
    		//open the menu

  • @Jitnaught thx and what do i write in my .ini file cause i dont got one yet

  • [Options]
    OpenMenuKey = F7

  • @Jitnaught thx for the fast response
    I will try it out tomorrow

  • @Jitnaught is there a way to do it in this without the "public"

        //This code will open the menu
        KeyDown += (o, e) =>
            if (e.KeyCode == OpenMenu && !_menuPool.IsAnyMenuOpen()) // Our menu on/off switch
                mainMenu.Visible = !mainMenu.Visible;


  • What do you mean by "public"?

  • Banned

    @Jitnaught public Test()

  • @ShadoFax the script is a class extending an other class Script.

    The line public Test() is the constructor of your class.

    Inside your constructor you set the code you want to execute once the mod is loaded.

    Search object oriented programming, C# classes, constructor if you wanna learn more about it.

    using GTA;

    public class Test : Script {
    public Test() {
    // will run when mod is loaded.
    // will run only once unless you reload scripts.

  • Banned

    @Konijima It's not my script.

  • @QBit07 well the code Jitnaught gave does exactly what he want.

    It read the setting at start then it attach a keydown handler, that check for the needed key press.

    I'm not sure I understand your problem also.
    Maybe elaborate on what you have right now and what doesn't work for you.

  • @Konijima
    QBit was just letting me know what he thinks Shado was talking about. QBit is not the one asking the question.

  • omg i was confused there alright sorry @QBit07 xD

  • Banned

    @Konijima How'd you do that strikethrough? It never works for me.

  • @Konijima thanks all, i'm using a nativeuitemplate and i dont know where to place that script i"ll send a pic soon so you all know what i mean

  • @QBit07 You must wrap your text between double ~~
    It wont work with paragraph so you must only wrap a single line of text with it, I think.

Log in to reply

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