AutoConfigs (SourceMod Scripting)
|Language:||English • 한국어|
SourceMod provides a system for simple plugins to automatically generate config files which get executed on load. This is done via the AutoExecConfig native in scripting/include/sourcemod.inc.
Once all configuration files are executed, OnConfigsExecuted is called. This forward will always be called, even if your plugin had no configs or if it was loaded late.
There are three parameters to this call:
- autoCreate - If true, SourceMod will dump all ConVars created by the plugin into a config file if the specified config file does not exist.
- name - Name of the config file (excluding the .cfg extension). If empty, the plugin's name will be used instead, with plugin. prepended. For example, hat.smx becomes plugin.hat.cfg.
- folder - Optionally change the folder under the main cfg folder. By default this is sourcemod, and configs go in cfg/sourcemod/. If empty, the config will be in cfg/.
Note: It is possible to write nested folders; SourceMod will attempt to create each one.
Note: If you have multiple AutoExecConfig calls marked with autoCreate being true, the first file to be auto created will prevent any others from being created. Thus, there is no way to automatically split cvars between multiple files.
Note: If a cvar has the flag FCVAR_DONTRECORD, it will not show up in the autoconfig. A good example of a use for this flag in a cvar, would be for the version cvar plugins need for the sake of tracking.
The autoCreate feature exports a config file that looks like this:
// This file was auto-generated by SourceMod (v184.108.40.2066) // ConVars for plugin "hat.smx" // MySQL database // - // Default: "" mysqlk_database "" // MySQL host, use this to configure various // things for your server. // - // Default: "localhost" mysqlk_host "localhost"