PDA

View Full Version : How can I remove a ConVar?


Shaman
08-16-2007, 15:34
How can I remove a ConVar created by a plugin?

Edit:
How can I prevent my plugin from loading if a required plugin isn't loaded?
For example, plugin2 can be loaded only if plugin1 is loaded.

BAILOPAN
08-16-2007, 16:15
http://wiki.alliedmods.net/Optional_Requirements_%28SourceMod_Scripting% 29

You cannot remove a ConVar. There really aren't many cases where doing that is a good idea.

Wilson [29th ID]
08-16-2007, 16:48
How can I prevent my plugin from loading if a required plugin isn't loaded?
For example, plugin2 can be loaded only if plugin1 is loaded.

Create a cvar in plugin1.

In plugin2, test if the cvar has a value. If so, plugin1 is loaded; if not, plugin1 is not loaded.

dalto
08-16-2007, 16:56
;519125']Create a cvar in plugin1.

In plugin2, test if the cvar has a value. If so, plugin1 is loaded; if not, plugin1 is not loaded.

cvar's don't go away when plugins are unloaded so the existence of a cvar does not imply that the plugin is loaded.

The link above describes how to create plugin dependencies.

Shaman
08-17-2007, 07:06
http://wiki.alliedmods.net/Optional_Requirements_%28SourceMod_Scripting% 29

You cannot remove a ConVar. There really aren't many cases where doing that is a good idea.
I thought a plugin should remove everything when it's unloaded, including ConVars.
---
I need a function like "IsPluginLoaded("basechat.smx")", because AdminTools: Source has to check if plugins like CS: S DM, GunGame: SM or ATAC and these plugins are not shared plugins.

ferret
08-17-2007, 12:18
SM cleans up the convars, you don't need to do it.

You can use this to see when basechat loads:

public OnLibraryRemoved(const String:name[])
{
if (StrEqual(name, "basechat"))
{
basechat= false;
}
}

public OnLibraryAdded(const String:name[])
{
if (StrEqual(name, "basechat"))
{
basechat= true;
}
}

Shaman
08-17-2007, 13:14
Can I do this with all plugins. (Advanced Team Atack Control, Deathmatch Team Balancer, CS: S DM, Heroes: Source, GunGame: SM, Say Sounds, SM Quake Sounds, SourceMod Radio, etc.)

BAILOPAN
08-17-2007, 13:26
cvars are special - if they're created by plugins, SourceMod keeps them around. The reason is that someone might want to unload a plugin and load it later, and still have the old value in-tact.

CS:S DM itself is an extension and it has slightly different rules, but everything you need to know is in the "Optional Requirements" article.