View Single Post
shanapu
Veteran Member
Join Date: Apr 2015
Location: .de
Old 07-21-2018 , 15:26   Re: Pass ConVar value to other plugins
Reply With Quote #5

Thanks for all your answers!

Quote:
Originally Posted by Dr!fter View Post
... Forwards are the best id say, and you can also force all submodules to update at any time by calling a forward (not sure if this is important).
Even though this is not an important feature for this plugin, for me this is the decisive argument for Forwards in general.

Quote:
Originally Posted by Dr!fter View Post
... You can also avoid calling FindConVar by using a forward when the cvar is created and forwarding the handle to all the submodules.
And that's fantastic! I didn't even think of passing the handle instead of the values. In this way, the submodules, can even change the master convars, like FindConvar if required.

Thank you very much!

For me, this topic is solved, but I'm still open to hearing new arguments!

edit: here a test snippet of passing convars handles:

Quote:
Master:
PHP Code:
public void OnPluginStart()
{
    
gc_sName CreateConVar("plugin_name""Name""");
    
gc_fTime CreateConVar("plugin_time""10.0""");
}
public 
APLRes AskPluginLoad2(Handle myselfbool latechar[] errorint err_max)
{
    
g_hSendConfig CreateGlobalForward("MyPlugin_Config"ET_IgnoreParam_CellParam_Cell);
}

public 
void OnConfigsExecuted()
{
    
Call_StartForward(g_hSendConfig);
    
Call_PushCell(gc_sName);
    
Call_PushCell(gc_fTime);
    
Call_Finish();

Module
PHP Code:
ConVar gc_sName;
ConVar gc_fTime;

public 
void MyPlugin_Config(ConVar nameConVar time)
{
    
gc_sName name;
    
gc_fTime time;

__________________
coding & free software

Last edited by shanapu; 07-21-2018 at 15:29.
shanapu is offline