Modding 101 - Knowledge Helps
-
I'm posting this for anyone interested, in the Installation Help & Troubleshooting forum, because the more you understand about the modding process, the more likely you are to fix your own issues. Hopefully it will also help identify terrible advice from Youtube videos, for example telling you to replace dinput8.dll with other files.
References: for accuracy, many of the definitions in this post are straight from wikipedia or other sources.
So, ever wonder why we need files like ScriptHook5 or what it does? Here are the basics as I understand them. Please post if I screwed up on anything or you need further clarification.
GTA5 looks for certain Windows files when you launch it. One of which is a Microsoft file called dinput8.dll. This file is installed automatically with the Windows OS and is a component of DirectX. It is found in the Windows System 32 folder.
However as it starts, GTA5 looks for dinput8.dll in its root folder first (the folder where GTA5 is installed). In the root folder, thanks to a programmer named Alexander Blade and once installed, it will find a different version of dinput8.dll (not the one in System 32) and it will load that file.
So in reality, it is dinput8.dll (also called the asi loader) that starts the mod process. It is a modified version of the Microsoft Windows dll of the same name and it works with functions in another Alexander Blade creation called ScripthookV.dll - it is this ScriptHook file which allows a hook into the GTA5 RAGE game engine and as a result makes the magic of modding possible.
The mod version of dinput8.dll works with the Windows version of dinput8.dll (peek at the file called asiloder.log) and also loads programs called asi plugins. These plugins include OpenIV.asi, ScriptHookVDotNet.asi, Menyoo.asi, TrainerV.asi, HeapAdjuster.asi, PackfileLimitAdjuster.asi, and NoBoundaryLimits.asi - just to name some of the most important and common ones.
In Blade's words, "Script Hook V is the library that allows us to use GTA V script native functions in custom .asi plugins. Note that it doesn't work in GTA Online, script hook closes GTA V when the player goes in multiplayer. In order to load asi plugins you need to have asi loader installed, you can download it separately or use the latest version that comes with this distrib (dinput8.dll). You must delete previous asi loader version (dsound.dll) if you have one installed."
Your trainer requires dinput8.dll to be loaded and Script Hook V for functionality. ScriptHookVDotNet (SHVDN) is also loaded by dinput8.dll and requires Script Hook V. The SHVDN will allow you to run your own scripts or mod scripts written in dot net versions of languages such as C# and VB.
Now what about OpenIV? Think of it as two separate programs, working together. The OpenIV you mod with allows you to install and edit files. The OpenIV.asi which is loaded by dinput8.dll will load your addons such as vehicles and maps and MLOs and even some peds - in fact anything called dlc.rpf. OpenIV gives you the option to install dinput8.dll (which it calls the asiloader), but you likely have already installed it with Script Hook V first.
Without getting into further detail, mod files such as heap limit adjusters, packfile limit adjusters, and the gameconfig.xml modded version are there to extend the limits of the game - they allow modders to increase the assets (peds, cars, MLOs, etc) beyond what the game can handle by default. Without them the game could crash due to memory issues. Of course there is no guarantee that your PC hardware can handle additional dlc - a common reason for why the game crashes.
-
Heap Limit Mods
Heap adjusters are there to help prevent memory allocation errors - specifically an error called ERR_MEM_EMBEDDEDALLOC_ALLOC.
What exactly is the heap? The heap is memory used by programming languages to store global variables. By default, all global variables are stored in heap memory space. It supports Dynamic memory allocation. Source: Stack vs Heap Memory – Difference Between Them
According to one of the mod authors, the default game heap size is 466MB. This is identified as vanilla heap size in a log file.
There are two versions of these mods available and you should only install one. They aren't mandatory but they should be, for anyone serious about modding and stability.
These are the 2 heap mods described in brief.
Heap Limit Adjuster 650 MB of heap! by hydrogen-cfx (FiveM Systems Division)
Last Updated: October 06, 2017This mod consists of one plugin, to be installed in the game folder (root). It will be loaded by dinput8.dll. It is set at 600MB and isn't configurable.
GTAV.HeapAdjuster.asi
HeapAdjuster by Dilapidated
Last Updated: August 03, 2019This is a newer version based on (a fork) of the citizenfx gtav-heap-adjuster (FiveM) above. It differs from the older one by having a configurable ini file and also generates a log file. It is also installed in the game folder and loaded by dinput8.dll. It is set higher at 750MB and is configurable through the included ini file.
Setting the heap in this mod's ini file above 750MB will not guarantee better results. Although I could not find references specifically for GTA5, based on Java documentation the maximum heap limit is about 2 GB (2048MB). In fact performance and stability could suffer if you exceed that. However feel free to experiment.
This mod is packaged with 2 files and will generate a log file.
HeapAdjuster.asi HeapAdjuster.ini HeapAdjuster.log (generated after first run)
-
Packfile Limit Mod
The Packfile Limit Adjuster mod is there to prevent a specific error: ERR_FIL_PACK_1. However after the Criminal Enterprises update, other errors related to this mod appeared such as unable-to-find-pattern #15 or unable-to-find-pattern #9 and the Packfile mod, originally released in 2018, was updated for the first time in July 2022. These pattern errors, which previously were rarely reported, were fixed for most users by the update.
There is only one version available. Like the heap mods, it isn't mandatory but it also should be considered such.
What are packfiles? This refers to dlcpacks, the mods we install as folders containing an archive called dlc.rpf (as mentioned in first post) as well as the dlc packs from Rockstar updates. This includes all addons for vehicles, MLOs, maps, and some Ped mods. Replace mods and xml mods are not in dlcpacks.
Packfile Limit Adjuster by alloc8or (Unknown Modder)
Last Updated: July 27, 2022This mod includes one plugin, to be installed in the game folder (root) and a configurable ini file. It will be loaded by dinput8.dll as will all asi plugins.
It is set by default, packfile_list_size = 5208. The author claims this is twice the amount of the default size in build 1493 which included After Hours for GTA 5 Online in 2018.
Once more, increasing this limit might not lead to stability gains, particularly with a PC lacking adequate RAM and VRAM or other hardware resources.
PackfileLimitAdjuster.asi PackfileLimitAdjuster.ini
The author recommends grouping dlcpacks. This is optional and like everything else has pros and cons. The pro is obviously that grouping dlcpacks into single folders reduces the total number of packs. This applies to vehicles.
The cons are numerous: the grouping process, either manually or through a mod, requires careful attention to detail and time and can be a huge PITA. It also increases complexity when editing files in OpenIV and makes troubleshooting more challenging - in other words which vehicle in the pack is causing a crash assuming you have crashes - and you will.
For those who aren't into game dlc or GTAO, you can delete the Rockstar dlcpacks as an alternative. Backup your files first.
Of course grouping or deleting isn't a substitute for a properly configured game with the appropriate hardware. Keep in mind that modding is pushing the game beyond its recommended state.
For the curious, you can view the packfile settings in the vanilla gameconfig.xml (the one in your games folder) for your specific build. As an example, using build 2372 it is 3672. Archive is Rockstar lingo for dlcpacks, which are archives - similar to zip, rar, and 7z archives (and also OIV installers).
<ConfigStreamingEngine> <ArchiveCount value="3672"/> <PhysicalStreamingBuffer value="252"/> <VirtualStreamingBuffer value="1000"/> </ConfigStreamingEngine>
-
Gameconfig.xml
Along with the Heap and Packfile limit adjusters, another custom file is required to create the GTA5 Stability Trinity. Unlike the first two, this isn't a plugin, it's a modded version of the vanilla gameconfig.xml file from the game folder.
Additionally, unlike the limit adjuster plugins, it can be edited because it is a text file. However there isn't any reason to modify this file unless you have stability/crashing issues - and you definitely need to know what you're doing.
Game vanilla version path:
\update\update.rpf\common\data
Mod version path:\mods\update\update.rpf\common\data
This post to be updated, this is just a placeholder for continuity.
-
FAQ
What is a plugin? A plugin is a software component that adds a specific feature to an existing computer program. When a game like GTA5 supports plug-ins, it enables modding and customization of the game.
What is a dll? A DLL is a library that contains code and data that can be used by more than one program at the same time. For example, in Windows operating systems, the Comdlg32 DLL performs common dialog box related functions. Each program can use the functionality that is contained in this DLL to implement an Open dialog box. It helps promote code reuse and efficient memory usage. It stands for Dynamic Link Library.
What is an API? API is the acronym for Application Programming Interface, which is a software intermediary that allows two applications to talk to each other. Each time you use an app like Facebook, send an instant message, or check the weather on your phone, you’re using an API.
What is dinput8.dll (Directinput8)? The dinput8.dll is an executable file on your computer's hard drive. This file contains machine code. If you start the software DirectX on your PC, the commands contained in dinput8.dll will be executed on your PC. For this purpose, the file is loaded into the main memory (RAM) and runs there as a Microsoft DirectInput DLL for DirectX 8 process (also called a task). The dinput8.dll file should be located in the folder C:\Windows\System32\dinput8.dll. Alexander Blade created a modified version of the same name, packaged with Script Hook V.
What is DirectX? Very simply DirectX allows games to "talk" to video cards. Microsoft DirectX is a collection of application programming interfaces (APIs) for handling tasks related to multimedia, especially game programming and video, on Microsoft platforms. Originally, the names of these APIs all began with "Direct", such as Direct3D, DirectDraw, DirectMusic, DirectPlay, DirectSound, and so forth. The name DirectX was coined as a shorthand term for all of these APIs (the X standing in for the particular API names) and soon became the name of the collection.
What is a hook? A hook, or hook library like Script Hook V, allows you to add hooks called by the game engine, allowing multiple scripts to modify game function. In other words it allows you to extend and mod the game itself.
What is a native function? A native function is a one of the functions exposed by the RAGE engine to be called from a script. In other words, native functions are the programming code in the engine allowing everything from spawning a ped or vehicle to creating animations etc.
Some abbreviations
DLC: downloadable content
rpf: rage package format, some call it rage package file. An RPF file is a game archive used by Grand Theft Auto (GTA) IV and V, action-adventure video games published by Rockstar Games. It contains game data files, such as 3D character models, texture graphics, and game audio. Modders often modify RPF files' contents to customize GTA IV and V. It is generally compressed and encrypted. GTA5 uses RPF7 version which is implemented into OpenIV.
RAGE: The Rockstar Advanced Game Engine (RAGE) is a proprietary game engine developed by RAGE Technology Group.
FILE TYPES. For more information about the GTA5 files, see this post.
-
More is not More for Modding
Beware of well intentioned but poorly conceived advice that maxing out parameters in heap, pack, and gameconfig.xml will fix crashing issues. The opposite is more likely true. You can find some truly moronic advice on YouTube and in the comment sections of the mods referenced above.
The sad truth is that increasing your heap size to a terabyte won't compensate for the fact you only have 8GB of RAM.
Similarly, increasing the pack parameters to 1 million won't allow you to install 50,000 vehicles and 10,000 peds along with every map and racetrack and MLO available in the mods section.
A stable modded system requires your hardware meets or hopefully exceeds recommendations for the vanilla game. It requires setting up the proper modding environment together with updated gameconfig.xml and heap and pack mods. It requires updated video drivers and in game visual settings that are appropriate for your hardware.
Tweaking parameters well past the recommendations by the mod authors, or well past those of common sense, will not compensate for underperforming hardware and will definitely not fix issues stemming from improperly installed mods, too many or outdated scripts, poorly designed vehicles, dlclist syntax errors, or Rockstar fuck you very much updates.
The same applies to the idiotic advice to replace Alexander Blade's version of dinput8.dll. Do you honestly think some moron on twitch or YouTube should know better than AB? Are you yourself going to second guess AB? Same applies to authors like @alloc8or and @Dilapidated. Are you going to trust their recommended settings or dismiss them in favor of some idiot's comment in the mods section which is along the lines of if x is recommended, then certainly x multplied by 100 must be better.
My only advice is don't start introducing more unknown variables when you're troubleshooting. On the contrary, leave things you don't fully understand alone, things that aren't even documented. Instead temporarily remove mods to simplify the troubleshooting process.
For the record, my gameconfig, packfile, and heap mods are all untouched, all at their default settings, and i do have close to a thousand mods installed with a very stable mid range desktop PC which i built from scratch. All my in game visual settings are maxed out. I don't use NVE or QuantV or similar garbage because my eyes, while not perfect, register colours, brightness, contrast, and saturation the way the game and nature intended.
-
The Secret Life of Gameconfig.xml
Unfortunately there isn't much documentation on the vanilla version of gameconfig.xml and just as little on the modded versions. Without documentation, was the mod created by trial and error? Only the authors know for sure and they're not sharing their secrets or we never asked them.
The good news is that both the game and the mod version are just plain text files. Using a free text editor such as Notepad++ you can strip the comments out and also blank lines and then use a free utility such as WinMerge to do side by side comparisons. The bad news, very bad news, is that there are thousands of lines to sift through without knowing exactly how each one will impact your game.
When you do that you can clearly see a process of increasing values on selected parameters. Are these values the sweetspots? Who knows. I'll be investigating further when i have a chance so follow along if you're still interested.
CLICK ON PICTURE BELOW FOR FULL SIZE - UNLESS YOU HAVE AMAZING EYESIGHT
-
Dlclist.xml
Although not strictly a mod, not in the "download/install" sense, this file is indeed modified and is one of the most important files for modders. When properly installed in the Mods folder, it replaces the function of the game version of dlclist.xml and tells the game to load your addons such as vehicles, peds, maps, and MLOs through OpenIV.asi - these are the mods contained in dlc.rpf packages.
This critical file will also include the vanilla game DLC (downloadable content) by default, which optionally you can remove if you choose to, with caution, as game/vanilla DLC can impact other mods.
There are actually 2 versions of dlclist.xml in the vanilla (unmodded) game. The lesser known one is found at the path
root folder\common.rpf
. They should not be confused. That one is unimportant for modders and contains just a few "platform" entries, for example:<Item>platform:\dlcPacks\mpBeach\</Item>
Note: by root folder, we mean the game folder where GTA5 is installed, regardless of where purchased. The folder containing GTA5.exe.
The better known dlclist.xml, the one relevant for modders, was introduced as Rockstar released dlc for GTA Online. It is located at
root folder\update\update.rpf\common\data
and is only editable with OpenIV because the update.rpf which contains it is encrypted.This is the version of dlclist.xml that is copied to the mods folder as part of update.rpf, either manually or by OpenIV's editor, resulting in a third version of dlclist.xml. It is located at
root folder\mods\update\update.rpf\common\data
. And, most importantly, this is the version you will edit to add entries for new mods.Note: that some mods, particularly OIV installers, will add a 4th version in your mods folder. If this occurs, you will find this final version at
root folder\Mods\common.rpf
When adding entries to dlclist.xml you need to exercise caution to ensure the xml syntax is correct, with proper open and close tags and proper spelling. In GTA5 SP (Single Player) the folder name (the one containing dlc.rpf) is always the one used in dlclist.xml. In the case of vehicles, the name to spawn the vehicle is generally the same as the folder name, but there are unfortunately exceptions.
DLC can be stored anywhere in your root folder, but by default, it will be in a folder called dlcpacks at
root folder\Mods\update\x64\dlcpacks
A typical entry in dlclist.xml, which is an xml text file, will look like this:
<Item>dlcpacks:/cobra/</Item>
With experience and attention to detail, you will avoid creating errors in dlclist.xml or at least know how to identify and fix issues.
An excellent tutorial on proper use and common issues, by our resident guru @a63nt-5m1th, can be found here Tutorial - dlclist.xml Troubleshooting/Syntax Rules. Strongly recommended reading.
Note: Contrary to what many modders put in their instructions, Windows folders are not case sensitive. This means you can call your Mods folder mods, or your Scripts folder scripts or other combinations. This is not necessarily the case for xml. As you will see if you read the tutorial linked above, you can have item or Item as valid xml but open and closing Item must have the same case, they must match. Similarly, if you spawn dlc (peds or vehicles) with your Trainer, you can use whatever case you want. Lara or lara, mustang or Mustang, either will spawn.