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

Loading config correctly (check config before precache).


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Hedgehog Fog
Senior Member
Join Date: Jun 2010
Location: Ukraine
Old 01-14-2016 , 17:59   Loading config correctly (check config before precache).
Reply With Quote #1

Hey there,
I have a little problem, problem with my mod.
I load cfg in function plugin_cfg(), but before that we have execute plugin_precache() and plugin_init(), where we setup our plugin, create hooks, precache resources and fix gameplay.
I need load main mod variable (enable/disable) and after that precache resources, remove entities and create hooks if main variable enabled. Based on this I need config before plugin_preacache() execute, which is impossible. If I load my config in plugin_precache() then data load with small delay and main mod variable set to loaded value after precache and hooks for removing entities will be created.
I need your help, guys, I need solution which will allow me not to ruin the gameplay if main variable in config set to disabled.
__________________

❄️ CS Snow Wars - Mod based on snowballs fights
🧟 CS Zombie Panic - A port of HL Zombie Panic!
🎃 CS Halloween Mod - Completely new gamemode for Halloween Holidays
📦 AMXXPack - CLI and build system for amxx projects
🔧 Custom Entities API - API to register custom entities

Last edited by Bugsy; 01-14-2016 at 18:40.
Hedgehog Fog is offline
Old 01-14-2016, 18:25
Hedgehog Fog
This message has been deleted by Hedgehog Fog. Reason: Solved
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-14-2016 , 18:31   Re: SOLVED!
Reply With Quote #2

Please post how you solved your issue, it can help others.
__________________
Bugsy is offline
Old 01-15-2016, 05:58
JusTGo
This message has been deleted by JusTGo.
Hedgehog Fog
Senior Member
Join Date: Jun 2010
Location: Ukraine
Old 01-22-2016 , 13:16   Re: Loading config correctly (check config before precache).
Reply With Quote #3

PHP Code:
new g_cvarEnable;
new 
bool:g_isEnabled;

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);

    if(!
g_isEnabled)
        return;

    
//Register hooks and cvars
}

public 
plugin_precache()
{
    
g_cvarEnable register_cvar("enable""1");
    
    
load_config();    
    
    
g_isEnabled get_pcvar_num(g_cvarEnable);
    
    if(!
g_isEnabled)
        return;

    
//Precache resources
}

load_config()
{
    new 
configsdir[32];
    
get_configsdir(configsdircharsmax(configsdir));
    
    
server_cmd("exec %s/mymod/config.cfg"configsdir);
    
server_exec();

__________________

❄️ CS Snow Wars - Mod based on snowballs fights
🧟 CS Zombie Panic - A port of HL Zombie Panic!
🎃 CS Halloween Mod - Completely new gamemode for Halloween Holidays
📦 AMXXPack - CLI and build system for amxx projects
🔧 Custom Entities API - API to register custom entities

Last edited by Hedgehog Fog; 01-22-2016 at 13:17.
Hedgehog Fog 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 06:02.


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