Merge pull request #266 from Arkshine/feature/autoexeccfg

Introduce automatic config file for plugins and two forwards
This commit is contained in:
Vincent Herbet
2015-08-26 10:42:59 +02:00
14 changed files with 550 additions and 44 deletions

View File

@ -82,8 +82,7 @@ public plugin_init()
new configsDir[64]
get_configsdir(configsDir, charsmax(configsDir))
server_cmd("exec %s/amxx.cfg", configsDir) // Execute main configuration file
server_cmd("exec %s/sql.cfg", configsDir)
// Create a vector of 5 cells to store the info.
@ -351,45 +350,6 @@ AddAdmin(id, auth[], accessflags[], password[], flags[], comment[]="")
SQL_FreeHandle(info)
#endif
}
public plugin_cfg()
{
set_task(6.1, "delayed_load")
}
public delayed_load()
{
new configFile[128], curMap[64], configDir[128]
get_configsdir(configDir, charsmax(configDir))
get_mapname(curMap, charsmax(curMap))
new i=0;
while (curMap[i] != '_' && curMap[i++] != '^0') {/*do nothing*/}
if (curMap[i]=='_')
{
// this map has a prefix
curMap[i]='^0';
formatex(configFile, charsmax(configFile), "%s/maps/prefix_%s.cfg", configDir, curMap);
if (file_exists(configFile))
{
server_cmd("exec %s", configFile);
}
}
get_mapname(curMap, charsmax(curMap))
formatex(configFile, charsmax(configFile), "%s/maps/%s.cfg", configDir, curMap)
if (file_exists(configFile))
{
server_cmd("exec %s", configFile)
}
}
loadSettings(szFilename[])

View File

@ -3190,5 +3190,47 @@ native admins_flush();
*/
native bool:has_map_ent_class(const classname[]);
/**
* Called when the map has loaded, and all configs are done executing.
* This includes servercfgfile (server.cfg), amxx.cfg, plugin's config, and
* per-map config.
*
* @note This is best place to initialize plugin functions which are based on cvar data.
* @note This will always be called once and only once per map. It will be
* called few seconds after plugin_cfg().
*
* @noreturn
*/
forward OnConfigsExecuted();
/**
* Called when the map has loaded, right after plugin_cfg() but any time
* before OnConfigsExecuted. It's called after amxx.cfg and all
* AutoExecConfig() exec commands have been added to the server command buffer.
*
* @note This will always be called once and only once per map.
*
* @noreturn
*/
forward OnAutoConfigsBuffered();
/**
* Specifies that the given config file should be executed after plugin load.
*
* @note OnConfigsExecuted() will not be called until the config file has executed,
* but it will be called if the execution fails.
*
* @param autoCreate If true, and the config file does not exist, such a config
* file will be automatically created and populated with
* information from the plugin's registered cvars.
* @param name Name of the config file, excluding the .cfg extension.
* If empty, <plugin.filename.cfg> is assumed.
* @param folder Folder under plugins/ to use.
*
* @noreturn
*/
native AutoExecConfig(bool:autoCreate = true, const name[] = "", const folder[] = "");
// Always keep this at the bottom of this file
#include <message_stocks>