AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   A simple question... (https://forums.alliedmods.net/showthread.php?t=324041)

AceVentura 05-04-2020 15:03

A simple question...
 
For a cvar to be accessible via a .cfg file, shall i do it like this?

PHP Code:

public plugin_init()
{
    
gCreditKill   =   register_cvar"normal_kill""1" )
    
gCreditHs    =   register_cvar"headshot_kill""2" )
    
gCreditHe    =   register_cvar"henade_kill""3" )
    
gCreditKnife =   register_cvar"knife_kill""5" )
    
gVipCosts     =   register_cvar"vip_costs""3600" )
     
    
LoadConfig()
}

LoadConfig( )
{
    new 
config[64];
    
get_configsdir(configcharsmax(config));
    
add(configcharsmax(config), "/credits.cfg");

    if(
file_exists(config)) 
    {
        
server_cmd("exec %s"config);
        
server_exec();
    }


And, then, add all cvars in the file. (credits.cfg in this case)

credits.cfg

OciXCrom 05-04-2020 15:11

Re: A simple question...
 
You should load the cvars in plugin_cfg(), not plugin_init().

PS: no matter how simple the question is, the thread needs to have a descriptive title.

AceVentura 05-04-2020 15:14

Re: A simple question...
 
Quote:

Originally Posted by OciXCrom (Post 2698171)
You should load the cvars in plugin_cfg(), not plugin_init().

Ah, thanks!
Quote:

Originally Posted by OciXCrom
PS: no matter how simple the question is, the thread needs to have a descriptive title.

Oops, sorry, my bad.


All times are GMT -4. The time now is 17:09.

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