AutoConfigs (SourceMod Scripting)

From AlliedModders Wiki
Revision as of 09:10, 18 April 2012 by Eakgnarok (talk | contribs)
Jump to: navigation, search
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.

Usage

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.


Example Dump

The autoCreate feature exports a config file that looks like this:

// This file was auto-generated by SourceMod (v1.0.0.986)
// 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"
Warning: This template (and by extension, language format) should not be used, any pages using it should be switched to Template:Languages

View this page in:  English  Russian  简体中文(Simplified Chinese)