AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [INC] Append new ConVars to plugin config v2.1 (https://forums.alliedmods.net/showthread.php?t=233282)

KissLick 01-12-2014 13:30

[INC] Append new ConVars to plugin config v2.1
 
1 Attachment(s)
Ciao,

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:AppendNote512 ] = ""bool:AlwaysAppend false 

When is config updating?
  1. When plugin version is not written in config file (those "// @version:" lines).
  2. When AlwaysAppend = true
Note: You will see all your ConVars on server console when is config updating.

Implementing:
  1. #include <convar_append>
  2. 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

Against my testing, there might be some bugs.. So let me know if you find someone please.

Change log:
Spoiler

Powerlord 01-15-2014 11:04

Re: [INC] Append new ConVars to plugin config
 
What's the different between this and the one Impact123 wrote?

KissLick 01-15-2014 12:11

Re: [INC] Append new ConVars to plugin config
 
You don't need to use special functions for creating ConVars etc.. This is easier to use.

berni 01-17-2014 09:18

Re: [INC] Append new ConVars to plugin config
 
Couldn't you just load the configuration file, delete it and then let AutoExecConfig create it again ?
This way it should add all Cvars automatically and would be just a few lines of code.

Mathias. 01-18-2014 01:11

Re: [INC] Append new ConVars to plugin config
 
the point of a configuration file is to save the configuration, not to delete it... It will put all cvars to default values which is unwanted but your idea it not totally wrong but would still need a new AutoExecConfig external since my idea was to load the cvars, delete old configs, and create new one (from scratch and not from sourcemod) to add the cvars at their current values plus the new cvars.

ddhoward 01-18-2014 01:28

Re: [INC] Append new ConVars to plugin config
 
And even if the new file generated by AutoExecConfig saved the current values rather than the defaults... Deleting the file would remove any comments that the server op may have placed in there.

berni 01-18-2014 12:41

Re: [INC] Append new ConVars to plugin config
 
Quote:

Originally Posted by Black-Rabbit (Post 2087470)
the point of a configuration file is to save the configuration, not to delete it... It will put all cvars to default values which is unwanted but your idea it not totally wrong but would still need a new AutoExecConfig external since my idea was to load the cvars, delete old configs, and create new one (from scratch and not from sourcemod) to add the cvars at their current values plus the new cvars.

No, the way I meant it would preserve the current values, not delete them.
I haven't find anything in the documentation, that the default values are used instead of the current ones, but yeah it of course doesn't work then.
It was just an idea how to maybe get away with less code.

Quote:

Originally Posted by ddhoward (Post 2087476)
And even if the new file generated by AutoExecConfig saved the current values rather than the defaults... Deleting the file would remove any comments that the server op may have placed in there.

That would be a very tiny downside when they get lost on plugin update. I don't remember ever having put comments in generated config files in 5 years. But there are maybe people who do that.

Mathias. 01-19-2014 02:23

Re: [INC] Append new ConVars to plugin config
 
Quote:

Originally Posted by ddhoward (Post 2087476)
And even if the new file generated by AutoExecConfig saved the current values rather than the defaults... Deleting the file would remove any comments that the server op may have placed in there.

comment a config, lol...

Chdata 01-27-2014 23:39

Re: [INC] Append new ConVars to plugin config
 
What's wrong with commenting configs?

If this saved new values in your cfg instead of making them default again, I'd use it!

Unless it already does, and I just misread.

KissLick 01-28-2014 12:43

Re: [INC] Append new ConVars to plugin config
 
I plan to make a better and smarter version after my exams, this is a little messy version.. O:-)


All times are GMT -4. The time now is 13:50.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.