Raised This Month: $12 Target: $400
 3% 

General way of adding a cvar to disable/enable a plugin?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
carlS
AlliedModders Donor
Join Date: Dec 2015
Location: Germany
Old 03-03-2017 , 15:11   General way of adding a cvar to disable/enable a plugin?
Reply With Quote #1

Hi everyone,

I want some plugins on our servers to interact with each other. That means that the one plugin may enable/disable another plugin. Since some of the plugins aren't being developed any further I wanted to change some of them so that I have a cvar to disable/enable that plugin.

Is there a general way of achieving this or does that always depend on the plugin?

Thanks.
__________________
Respawn-Gaming: respawn-gaming.com

"Only the unknown frightens men. But once a man has faced the unknown, that terror becomes the known."
- Antoine de Saint-Exupery
carlS is offline
Weetabix
Member
Join Date: Feb 2017
Location: United Kingdom
Old 03-03-2017 , 17:37   Re: General way of adding a cvar to disable/enable a plugin?
Reply With Quote #2

Convars or natives is my guess.
Weetabix is offline
shanapu
Veteran Member
Join Date: Apr 2015
Location: .de
Old 03-03-2017 , 17:56   Re: General way of adding a cvar to disable/enable a plugin?
Reply With Quote #3

Quote:
Originally Posted by KarlmitC View Post
...

Is there a general way of achieving this or does that always depend on the plugin?

Thanks.
It's depending on the plugin. You must investigate the code and find where the functions apply.
I was faced with the same problem with myjailbreak and ended with a mix of creating convars & natives. Whether you use natives or convars is depending on the plugins & the way they need to interact with each other.
__________________
coding & free software

Last edited by shanapu; 03-03-2017 at 17:58.
shanapu is offline
carlS
AlliedModders Donor
Join Date: Dec 2015
Location: Germany
Old 03-03-2017 , 18:01   Re: General way of adding a cvar to disable/enable a plugin?
Reply With Quote #4

Quote:
Originally Posted by shanapu View Post
It's depending on the plugin. You must investigate the code and find where the functions apply.
I was faced with the same problem with myjailbreak and ended with a mix of creating convars & natives. Whether you use natives or convars is depending on the plugins & the way they need to interact with each other.
Thanks for the answer, just wanted to make sure that I don't start getting into the code and in the end i didn't even need to.
I'll have to try to get it working with one convar in the end, because the best way for my other plugins would be if they could just change that one.
__________________
Respawn-Gaming: respawn-gaming.com

"Only the unknown frightens men. But once a man has faced the unknown, that terror becomes the known."
- Antoine de Saint-Exupery
carlS is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 03-03-2017 , 18:06   Re: General way of adding a cvar to disable/enable a plugin?
Reply With Quote #5

Quote:
Originally Posted by KarlmitC View Post
Thanks for the answer, just wanted to make sure that I don't start getting into the code and in the end i didn't even need to.
I'll have to try to get it working with one convar in the end, because the best way for my other plugins would be if they could just change that one.
I mean, you should always have some sort of algorithm or plan before you start doing anything.


If you have a plugin in which you want to create a convar to disable it, just don't allow it's commands & gameplay modifications to be called if the convar says it should be disabled. For example, in command callbacks just tell the user it's disabled. Simple stuff like that
headline is offline
sdz
Senior Member
Join Date: Feb 2012
Old 03-03-2017 , 22:56   Re: General way of adding a cvar to disable/enable a plugin?
Reply With Quote #6

or, or, or..
FindConVar
sdz is offline
carlS
AlliedModders Donor
Join Date: Dec 2015
Location: Germany
Old 03-04-2017 , 09:23   Re: General way of adding a cvar to disable/enable a plugin?
Reply With Quote #7

Quote:
Originally Posted by EasSidezz View Post
or, or, or..
FindConVar
Yes, I wanted to do it somewhat like that, because the plugin consists of multiple files and I'd need always to check that specific cvar, right?
__________________
Respawn-Gaming: respawn-gaming.com

"Only the unknown frightens men. But once a man has faced the unknown, that terror becomes the known."
- Antoine de Saint-Exupery
carlS is offline
sdz
Senior Member
Join Date: Feb 2012
Old 03-04-2017 , 10:41   Re: General way of adding a cvar to disable/enable a plugin?
Reply With Quote #8

Quote:
Originally Posted by KarlmitC View Post
Yes, I wanted to do it somewhat like that, because the plugin consists of multiple files and I'd need always to check that specific cvar, right?
Yeah, you could run FindConVar on OnAllPluginsLoaded, assign a global Handle to it then HookConVarChange that Handle

Last edited by sdz; 03-04-2017 at 10:41.
sdz 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 14:13.


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