AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   General way of adding a cvar to disable/enable a plugin? (https://forums.alliedmods.net/showthread.php?t=294621)

carlS 03-03-2017 15:11

General way of adding a cvar to disable/enable a plugin?
 
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. :)

Weetabix 03-03-2017 17:37

Re: General way of adding a cvar to disable/enable a plugin?
 
Convars or natives is my guess.

shanapu 03-03-2017 17:56

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

Originally Posted by KarlmitC (Post 2500491)
...

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.

carlS 03-03-2017 18:01

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

Originally Posted by shanapu (Post 2500534)
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.

headline 03-03-2017 18:06

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

Originally Posted by KarlmitC (Post 2500540)
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

sdz 03-03-2017 22:56

Re: General way of adding a cvar to disable/enable a plugin?
 
or, or, or..
FindConVar

carlS 03-04-2017 09:23

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

Originally Posted by EasSidezz (Post 2500568)
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?

sdz 03-04-2017 10:41

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

Originally Posted by KarlmitC (Post 2500689)
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


All times are GMT -4. The time now is 01:11.

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