Raised This Month: $32 Target: $400
 8% 

[INC] Append new ConVars to plugin config v2.1


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 01-12-2014 , 13:30   [INC] Append new ConVars to plugin config v2.1
Reply With Quote #1

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
Attached Files
File Type: inc convar_append.inc (6.6 KB, 401 views)

Last edited by KissLick; 02-17-2014 at 03:10. Reason: New version
KissLick is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 01-15-2014 , 11:04   Re: [INC] Append new ConVars to plugin config
Reply With Quote #2

What's the different between this and the one Impact123 wrote?
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 01-15-2014 , 12:11   Re: [INC] Append new ConVars to plugin config
Reply With Quote #3

You don't need to use special functions for creating ConVars etc.. This is easier to use.
KissLick is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 01-17-2014 , 09:18   Re: [INC] Append new ConVars to plugin config
Reply With Quote #4

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.
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0
berni is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 01-18-2014 , 01:11   Re: [INC] Append new ConVars to plugin config
Reply With Quote #5

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.

Last edited by Mathias.; 01-18-2014 at 01:14.
Mathias. is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 01-18-2014 , 01:28   Re: [INC] Append new ConVars to plugin config
Reply With Quote #6

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.
__________________
ddhoward is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 01-18-2014 , 12:41   Re: [INC] Append new ConVars to plugin config
Reply With Quote #7

Quote:
Originally Posted by Black-Rabbit View Post
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 View Post
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.
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0
berni is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 01-19-2014 , 02:23   Re: [INC] Append new ConVars to plugin config
Reply With Quote #8

Quote:
Originally Posted by ddhoward View Post
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...
Mathias. is offline
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 01-27-2014 , 23:39   Re: [INC] Append new ConVars to plugin config
Reply With Quote #9

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.
__________________
Chdata is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 01-28-2014 , 12:43   Re: [INC] Append new ConVars to plugin config
Reply With Quote #10

I plan to make a better and smarter version after my exams, this is a little messy version.. O:-)
KissLick is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:25.


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