Log in to reply
 

(Question) Modding .dll scripts



  • I would really appreciate some links to tutorials explaining how to create and compile such mods. Google didn't provide anything useful on that matter.

    More precisely I'm interested in how to add custom .ini file with settings to already existing .dll, are there any universal commands, like key bindings I can use for any .dll mod or this have to be written in .dll file itself to take effect?




  • MODERATOR

    With SHV.NET, I do something like this:

    Void INISettings()
    {
    String path = "scripts\Settings.ini";
    ScriptSettings config = ScriptSettings.Load(@path);

    //Now for example, you want to get a float named Height from your ini file, just do this:

    Height = config.GetValue<float>("Settings", "Height", 10f);

    //"Settings" is the section. It will appear as [Settings] in the ini.
    //"Height" will appear as Height under [Settings]
    //10f is just the default value that Height will be if the ini setting isn't found or can't be read.

    }

    So every time you call this function, your script will read from the ini file.

    Your ini file should look like this:
    [Settings]
    Height = 20
    ;This is a comment.

    For floats, don't place the "f" after the number or it won't read. I don't know why it's like this.

    You will have to create the ini file manually and write the settings manually this way. But if you want to write to the ini file, it's pretty similar:

    Void SaveToINI()
    {
    String path = "scripts\Settings.ini";
    config = ScriptSettings.Load(@path);

    config.SetValue<float>("Settings", "Height", 10f);
    //Change 10f to the value you want to write to the ini. Say Height changes and you want to capture what it is to the ini when you press a key, change 10f to Height. So now when you call this functionn, it will write whatever Height is to your ini file.
    }

    You would still need the ini file to actually exist . You can do something like

    String path = "scripts\Settings.ini";
    if (!File.Exists(@path))
    {
    File.Create(@path);
    }
    else
    {
    SaveToINI();
    }

    I am on mobile so I can't be too sure if everything is correct, but I hope it helps!



  • Thanks a lot, it's really helpful.



  • Is ScriptSettings a ScriptHookVdotNET thing?

    I made my own crappy class using GetPrivateProfileInt/String for ScriptHookV.


Log in to reply
 

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