AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [INCLUDE] AutoExecConfig: Read and append to auto configs (https://forums.alliedmods.net/showthread.php?t=204254)

TnTSCS 07-30-2013 09:55

Re: [INCLUDE] Autoexecconfig read and append beta
 
nice - thank you Impact!

Silvers 07-30-2013 12:36

Re: [INCLUDE] Autoexecconfig read and append beta
 
Very nice work, I have only just seen this thread.

I made a plugin which does something similar. Backup the cvar configs, have plugins generate new configs and update any custom cvar values. http://forums.alliedmods.net/showthread.php?t=188756 for those plugins which do not use the include.

Impact123 08-05-2013 13:10

Re: [INCLUDE] Autoexecconfig read and append beta
 
Another Update.
Thanks to Peace-Maker, the include is now a little bit easier to use, especially for bigger plugins.

Instead of using
PHP Code:

AutoExecConfig(true"plugin.myplugin"); 

You now can simply use this
PHP Code:

AutoExecConfig_ExecuteFile(); 

This makes an internal call to AutoExecConfig with the data you set by AutoExecConfig_SetFile.

The include is now able to create the configfile by itself if it doesn't exists, by default this is disabled and can be enabled like this
PHP Code:

AutoExecConfig_SetCreateFile(true); 

To those who haven't noticed, thanks to TnTSCS you can now use newline characters in your convar description like so
PHP Code:

AutoExecConfig_CreateConVar("newlinetest""SomeCvar""This\nIs\nA\nNewline\nTest"FCVAR_PLUGIN); 

The result will look something like this

PHP Code:

// This
// Is
// A
// Newlie
// Test
// Default: "SomeCvar"
newlinetest "SomeCvar" 

Yours sincerely
Impact

TnTSCS 08-05-2013 13:12

Re: [INCLUDE] Autoexecconfig read and append beta
 
Thank you Impact :)

Now I'll be using this for all plugins, including the first release :D

thetwistedpanda 08-21-2013 14:02

Re: [INCLUDE] Autoexecconfig read and append beta
 
Just now finding this, where has this been all my life! Now to update all my plugins to use it.

Side note, missing ; on line 154.

TnTSCS 08-21-2013 16:44

Re: [INCLUDE] Autoexecconfig read and append beta
 
yes, I meant to post that earlier today about the missing ;

The end of line 150 is where it needs a ";"

strcopy(g_sFolderPath, sizeof(g_sFolderPath), folder)

Pull request sent

Impact123 08-21-2013 17:15

Re: [INCLUDE] Autoexecconfig read and append beta
 
My personal coding style is that i use the semicolon enforcing after including files, because of that i couldn't saw the warning.
The pull request by TnTSCS was merged (thank you), and the order of the pragmas in the testsuite were switched, it shouldn't happen again.
Thanks for letting me know, sorry for the inconveniences.

Yours sincerely
Impact

Bittersweet 12-07-2013 17:47

Re: [INCLUDE] Autoexecconfig read and append beta
 
I would like to use this, but perhaps it doesn't do what I thought. I see that it's adding new cvars, but none of the default values change when I change them, not even the version. Does this not update default values, descriptions, etc. of existing cvars?

Edit:
What I want, is that when I update a plugin, the user's corresponding .cfg file automatically:
1. Updates all of the data to existing cvar, such as default value, description, minimum value
2. Adds any new cvars
3. Removes any cvars that have been removed from the plugin
4. If a cvar already exists, leaves any user entered values in place
5. User comments left in place

What I don't care about so much:
User commands/cvars unrelated to the plugin being removed

Does this include have all of those, or part of those capabilities?

dordnung 12-07-2013 17:52

Re: [INCLUDE] Autoexecconfig read and append beta
 
How would you change to default value?

Bittersweet 12-07-2013 18:05

Re: [INCLUDE] Autoexecconfig read and append beta
 
Quote:

Originally Posted by Popoklopsi (Post 2069769)
How would you change to default value?

PHP Code:

AutoExecConfig_CreateConVar("myplugin_version"PLUGIN_VERSION"Version of myplugin"FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY

Above, the default value for myplugin_version is specified as PLUGIN_VERSION. When PLUGIN_VERSION changes, the default value changes.


All times are GMT -4. The time now is 08:44.

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