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

Make plugin_prechase called after plugin_cfg


Post New Thread Reply   
 
Thread Tools Display Modes
D3XT3R
AlliedModders Donor
Join Date: Nov 2016
Location: Lithuania, Bomb A (Kauna
Old 11-11-2017 , 07:39   Re: Make plugin_prechase called after plugin_cfg
Reply With Quote #21

Quote:
Originally Posted by HamletEagle View Post
He is right, calm down.
so no way :/ to make models change with cvars? intro cfg fille :/
__________________
D3XT3R is offline
Send a message via Skype™ to D3XT3R
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 11-11-2017 , 07:44   Re: Make plugin_prechase called after plugin_cfg
Reply With Quote #22

Quote:
Originally Posted by D3XT3R View Post
so no way :/ to make models change with cvars? intro cfg fille :/
IMO it is stupid to do that. If an admin changes the cvar mid game the server will crash.
__________________
HamletEagle is offline
aron9forever
Veteran Member
Join Date: Feb 2013
Location: Rromania
Old 11-11-2017 , 10:10   Re: Make plugin_prechase called after plugin_cfg
Reply With Quote #23

nobody said that you can't use a config file
people are saying you can not use a CVAR

there is nothing stopping you from creating your own config file format, reading it manually at precache with fopen and parsing it for your models, like many other plugins are doing, but it is impossible to use a cvar for this (it will work, but your cvar will always have default value, since it's being set after you check it, so then what's the point?)
__________________
Meanwhile, in 2050:
Quote:
Originally Posted by aron9forever
useless small optimizations
Quote:
Originally Posted by Black Rose View Post
On a map that is 512x512x128 units you end up with 3,355,443,200,000 different "positions". To store each one of those positions individually in the variable "user_or" you need 12 terabytes of memory.

Last edited by aron9forever; 11-11-2017 at 10:10.
aron9forever is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 11-11-2017 , 12:34   Re: Make plugin_prechase called after plugin_cfg
Reply With Quote #24

Quote:
Originally Posted by aron9forever View Post
nobody said that you can't use a config file
people are saying you can not use a CVAR

there is nothing stopping you from creating your own config file format, reading it manually at precache with fopen and parsing it for your models, like many other plugins are doing, but it is impossible to use a cvar for this (it will work, but your cvar will always have default value, since it's being set after you check it, so then what's the point?)
Actually not, IIRC. Cvars are saved once they are changed, so for example if you read it in precache it will have the value from the previous map, or in other words you need to change the map to make the cvar have an effect in this scenario.
The default value is not always enforced.

I can be wrong tho, and I'm too lazy to check.
__________________

Last edited by HamletEagle; 11-11-2017 at 12:34.
HamletEagle is offline
aron9forever
Veteran Member
Join Date: Feb 2013
Location: Rromania
Old 11-11-2017 , 21:55   Re: Make plugin_prechase called after plugin_cfg
Reply With Quote #25

Quote:
Originally Posted by HamletEagle View Post
Actually not, IIRC. Cvars are saved once they are changed, so for example if you read it in precache it will have the value from the previous map, or in other words you need to change the map to make the cvar have an effect in this scenario.
The default value is not always enforced.

I can be wrong tho, and I'm too lazy to check.
that is right actually, but it will still crash if you change it live, so if you only read a custom cfg on plugin_precache and then cache those values, it should be safe

I believe that's how other plugins do it
__________________
Meanwhile, in 2050:
Quote:
Originally Posted by aron9forever
useless small optimizations
Quote:
Originally Posted by Black Rose View Post
On a map that is 512x512x128 units you end up with 3,355,443,200,000 different "positions". To store each one of those positions individually in the variable "user_or" you need 12 terabytes of memory.
aron9forever is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 11-12-2017 , 03:33   Re: Make plugin_prechase called after plugin_cfg
Reply With Quote #26

Quote:
Originally Posted by aron9forever View Post
that is right actually, but it will still crash if you change it live, so if you only read a custom cfg on plugin_precache and then cache those values, it should be safe

I believe that's how other plugins do it
I agree. In ERR I'm using config files for models/sounds/sprites.
__________________

Last edited by HamletEagle; 11-12-2017 at 03:34.
HamletEagle is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 11-12-2017 , 04:59   Re: Make plugin_prechase called after plugin_cfg
Reply With Quote #27

I guess you could do
Code:
server_cmd("exec path/to/file.cfg");
server_exec();
in plugin_precache and put cvars in that file. I have never done that, but I guess it could work.

Also it's a misconception that config files are executed at plugin_cfg. I don't know about older versions of AMXX, but currently plugin_cfg gets called once all plugins get initialized (had plugin_init called for them). It's badly named.

Last edited by klippy; 11-12-2017 at 05:04.
klippy is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-12-2017 , 05:35   Re: Make plugin_prechase called after plugin_cfg
Reply With Quote #28

You can still precache in plugin_init/cfg() with EngFunc_PrecacheModel/Sound/Generic.
__________________

Last edited by Arkshine; 11-12-2017 at 05:35.
Arkshine is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 11-12-2017 , 07:28   Re: Make plugin_prechase called after plugin_cfg
Reply With Quote #29

But the cvars will still be useless since changing them will be impossible.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 11-12-2017 , 07:44   Re: Make plugin_prechase called after plugin_cfg
Reply With Quote #30

I don't think the game cares when you register or change cvars or execute config files. I guess I'll test it.

EDIT:
Tested, works. If I change the cvar in the file and change the map, I retrieve the new value.
PHP Code:
#include <amxmodx>
#include <amxmisc>

#pragma semicolon true

public plugin_init()
{
    
register_plugin("Cvars Test""1.0.0""KliPPy");
}

public 
plugin_precache()
{
    new const 
testCvar register_cvar("my_test_cvar""1337");
    new 
configFilePath[256];
    
    
get_configsdir(configFilePathcharsmax(configFilePath));
    
add(configFilePathcharsmax(configFilePath), "/cvartest.cfg");
    
server_cmd("exec %s"configFilePath);
    
server_exec();
    
    
log_amx("my_test_cvar = %i"get_pcvar_num(testCvar));


Last edited by klippy; 11-12-2017 at 07:58.
klippy 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 22:08.


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