Global Shared CVARS - How To ?
I have multiple plugins that share the same CVAR. They function independent of each other.
Any of these plugins can be used together so the problem arises when it comes to the CVAR being registered for the first time. How do I register a CVAR before hand so that it is available for all plugins to use. Right now I am doing this in all the plugins (Actually this block is being commonly included from a customized amxmisc.inc) PHP Code:
Is there any way to declare a CVAR before hand so that its existence need not be checked each time. I don't really want to create a dummy plugin to do this. And even so it would have to be the FIRST entry in plugins.ini so that it gets executed first. Is there any command or anything could be placed in amxx.cfg to create a CVAR ? |
Re: Global Shared CVARS - How To ?
I do believe I've seen something like a cvar, command manager round here but I think they might be a bit much for what you need. Just checking cvars in plugin_init() is better since server load is at it's minimum.
Also AMXX does NOT provide any mechanism of pre-declaring stand-alone cvars (it has something to do with cvar registration and owner plugin). Moving forward, you could edit an always-active amxx plugin and create the cvar there, leaving the rest of the plugins to just access it. EDIT: Or you could declare the cvar pointer as public and thus fully exposing it to other plugins. |
Re: Global Shared CVARS - How To ?
Maybe I'm completely missing your problem, but..
Code:
register_cvar("a_cvar", "1");If these plugins are only for personal use then why not register the cvar in admincmd.sma or one of the other base add-ons..? In fact, why is this such an issue in the first place? plugin_init() should be the last place you look at optimising. The rest of the code should be perfect before you even consider this. |
Re: Global Shared CVARS - How To ?
You could register it in one of the plugins plugin_precache..
Then it will already be there in all of the plugin_init's, so you wont need to check if it exsits. |
Re: Global Shared CVARS - How To ?
Again:
Just doing this in plugin_init() is ok !!! The overload is irrelevalnt !!! |
Re: Global Shared CVARS - How To ?
Lee is completely correct.
It doesn't matter how many plugins register a cvar, if it has already been registered when another call is made, register_cvar() will act basically like get_cvar_pointer(), and give you the pointer to it for use with pcvars. The value of the already existing cvar will not be changed by subsequent calls to it via register_cvar(). Additionally, no plugins "own" a cvar. It is open for anything within the engine to use freely. There is no need whatsoever to make a central repository of cvar pointers, or exposing cvar pointers via public variables. |
Re: Global Shared CVARS - How To ?
Quote:
This is the feature I was making http://forums.alliedmods.net/showthread.php?t=55956 |
Re: Global Shared CVARS - How To ?
Quote:
Code:
amx_override_spec = register_cvar("amx_override_spec","1")If so then this seems to be the best option. Because I CANNOT add any code in the plugins themselves, everything must be contained in the include file. |
Re: Global Shared CVARS - How To ?
Quote:
|
| All times are GMT -4. The time now is 10:40. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.