I made a simple replacement for AutoExecConfig ;-)
PHP Code:
/** * Append new ConVars to config file on new plugin version. * * @param name Name of the config file, excluding the .cfg extension. * If empty, <plugin.filename.cfg> is assumed. * @param folder Folder under cfg/ to use. By default this is "sourcemod." * @param AppendNote Note for server master about appended ConVars or just about appending. * @param AlwaysAppend Always try to append new ConVars and do not look at plugin version. (useful for developer release) * * @noreturn */ stock AutoExecConfigAppend( const String:name[] = "", const String:folder[] = "sourcemod", String:AppendNote[ 512 ] = "", bool:AlwaysAppend = false )
When is config updating?
When plugin version is not written in config file (those "// @version:" lines).
When AlwaysAppend = true
Note: You will see all your ConVars on server console when is config updating.
Implementing:
#include <convar_append>
Replace "AutoExecConfig" with "AutoExecConfigAppend" - no special functions for creating convars etc. needed.
Note: AutoExecConfigAppend will log message about appending ConVars to SourceMod logs.
Important note: If AutoExecConfigAppend do not append all ConVars, change "#define CONVAR_APPEND_MAXCHARS 4096" to higher value (in convar_append.inc line 7).
Example:
Spoiler
plugin release v0.1
PHP Code:
#include <sourcemod> #include <convar_append>
public Plugin:myinfo = { name = "TestConVarsList", author = "Raska", description = "TestConVarsList", version = "0.1", url = "" }
public OnPluginStart() { CreateConVar( "sm_cvar1", "1", "ConVar description for cvar 1..." ); CreateConVar( "sm_cvar3", "3.5", "ConVar description for cvar 3..." ); CreateConVar( "sm_cvar4", "Ciao", "ConVar description for cvar 4..." );
AutoExecConfigAppend(); }
and config would be like:
Code:
// Append new ConVars for plugin TestConVarsList.smx
// @version: 0.1
// ConVar description for cvar 1...
// -
// Default: "1"
sm_cvar1 "1"
// ConVar description for cvar 3...
// -
// Default: "3.5"
sm_cvar3 "3.5"
// ConVar description for cvar 4...
// -
// Default: "Ciao"
sm_cvar4 "Ciao"
plugin release v0.2
PHP Code:
#include <sourcemod> #include <convar_append>
public Plugin:myinfo = { name = "TestConVarsList", author = "Raska", description = "TestConVarsList", version = "0.2", url = "" }
AutoExecConfigAppend( _, _, "Just a little note about this ConVar append..\n\t- Delete ConVar sm_cvar3\n\t- ConVar sm_cvar7 is not integer but float now!" ); }
and config would be like:
Code:
// Append new ConVars for plugin TestConVarsList.smx
// @version: 0.1
// ConVar description for cvar 1...
// -
// Default: "1"
sm_cvar1 "1"
// ConVar description for cvar 3...
// -
// Default: "3.5"
sm_cvar3 "3.5"
// ConVar description for cvar 4...
// -
// Default: "Ciao"
sm_cvar4 "Ciao"
// Append new ConVars for plugin TestConVarsList.smx
// @version: 0.2
// @note: Just a little note about this ConVar append..
// - Delete ConVar sm_cvar3
// - ConVar sm_cvar7 is not integer but float now!
// ConVar
// description
// for
// cvar
// 7...
// (multiline)
// -
// Default: "7"
sm_cvar7 "7"
// ConVar description for cvar 8...
// -
// Default: "8.4"
// Minimum: "0.000000"
// Maximum: "96.529998"
sm_cvar8 "8.4"
// ConVar description for cvar 9...
// -
// Default: "-6.5"
// Maximum: "10.000000"
sm_cvar9 "-6.5"
And log message looks like this:
Code:
L 01/30/2014 - 19:07:16: [TestConVarsList.smx] ConVars appended to file "cfg/sourcemod/plugin.TestConVarsList.cfg" (version: "0.2")
Against my testing, there might be some bugs.. So let me know if you find someone please.
Change log:
Spoiler
2.1
Minor change about String:CommandOutPut[] size -> added "#define CONVAR_APPEND_MAXCHARS 4096", change 4096 to higher value if you need.
2.0
Many fixes..
Added plugin version based ConVar appendig.
Added func. argument "AppendNote" for short note about append.
Added func. argument "AlwaysAppend" for force always try to append new ConVars.
1.0
Initial release.
Last edited by KissLick; 02-17-2014 at 03:10.
Reason: New version