Copying ConVars
Hi,
At the moment my ZombieMod plugin uses long prefixes for it's cvars [zombie_] and I'd like to offer an alternative while still keeping the old ones. What would be the best way to go about it while keeping the cvars in synch with one another, will I really have to check each one in a callback and change the value of the other once I do manage to replicate them all? Thanks in advance, c0ld |
Re: Copying ConVars
You can create all the ConVar's using the same callback, then replace "zombie_" with "", format "zm_" to prefix, and SetConVar.
|
Re: Copying ConVars
Quote:
|
Re: Copying ConVars
Hmm, details? What I had in mind was this type of setup. Please excuse my psuedo-C
CreateConsoleVariable("zombie_a", "description for a", "1", CallbackGlobal); CreateConsoleVariable("zm_a", "description for a", "1", CallbackGlobal); CreateConsoleVariable("zombie_b", "description for b", "2.5", CallbackGlobal); CreateConsoleVariable("zm_b", "description for b", "2.5", CallbackGlobal); // global callback void CallbackGlobal(const char *ConvarName, const char *OldValue, const char *NewValue) { // check if ConvarName is prefixed with either zombie_ or zm_, substr() stuff // if it is prefixed, replace with the counter prefix and bam... SetConsoleVariable(CounterPrefixedName, NewValue); } |
Re: Copying ConVars
Hey Pimp,
The double declarations is what I'm trying to avoid, I wanted to loop my convar container and create copies which I could alter so even as I add new ones I won't need duplicate declarations. The Callback I was expecting no matter what as no matter how I duplicate them be it manully with duplicate vars or i find a way to programmaticaly do it they will still be two distinct cvars. Thanks for your input so far pimpin, c0ld |
Re: Copying ConVars
Hmm, I see what you are saying. Maybe you can hook the input of the server console?
PSUEDO Code:
Hook ServerConsoleInput |
Re: Copying ConVars
I have most of it figured out... The only remaining part I can't seem to get down is how to get a list of my plugins cvars before ConVar_Register is called. They only appear in the list after that call and by then it'll be too late to hitch a free ride on the cvar automation :)
|
Re: Copying ConVars
This code works and doesn't knock out anything else but none of the new cvars show up in 'meta cvars' nor do they act like cvars, I've tried changing paernt to the convar itself with the same result.
Any ideaS? Code:
#if defined ORANGEBOX_BUILD |
Re: Copying ConVars
I've sort of solved it...
Code:
#define CreateConvar( sName, sDefault, lFlags, sHelp, bMin, fMin, bMax, fMax, oCallback ) \ |
All times are GMT -4. The time now is 13:57. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.