Raised This Month: $ Target: $400
 0% 

Need help: reading out CVAR doesn't return expected result


Post New Thread Reply   
 
Thread Tools Display Modes
BAILOPAN
Join Date: Jan 2004
Old 09-22-2005 , 21:14  
Reply With Quote #11

Yes, that's the case. The server won't always execute cfgs right away. This is what server_exec() is for, flushing the execution buffer, I think.

But using it is dangerous, if there's no buffer, it'll crash. I think you're only supposed to use it after execing config files.
__________________
egg
BAILOPAN is offline
MistaGee
Senior Member
Join Date: Aug 2004
Location: Germany (Fulda)
Old 09-23-2005 , 04:44  
Reply With Quote #12

you could try delaying execution of the get_cvar_* functions for a second or two by using set_task, but then you'd have to make sure that the script stays inactive until this task has been executed... this way the server would at least have time to exec the config.


Greetz MGee
__________________
Ich hab nie behauptet dass ich kein Genie bin!
Mumble-Django: A web interface for Mumble
MistaGee is offline
Send a message via ICQ to MistaGee
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 09-23-2005 , 05:30  
Reply With Quote #13

You could also parse the config file yourself. I did this very thing in my Restrict Names plugin.

For another example of the exact same thing, you could check out Anti-Bigot which is the plugin where I initially stole the code for reading the config file.
Brad is offline
azrael
Member
Join Date: Jul 2005
Location: Denmark
Old 09-23-2005 , 08:29  
Reply With Quote #14

Thank you all for your valuable input! I'll probably fall back on Brad's suggestion of parsing the config file myself. Seems like the best way to go about it. I might give server_exec() a whirl too... It may just do the trick in my case...

Regards,
az
__________________
''This calls for a delicate blend of psychology and extreme violence.'' - Homer Simpson
azrael is offline
azrael
Member
Join Date: Jul 2005
Location: Denmark
Old 09-23-2005 , 10:38  
Reply With Quote #15

Well, seems like server_exec() does the trick all by itself. What are the odds of a crash if I call it right after executing the config file in plugin_init()?

I'm going to keep the read out in plugin_cfg(), just to have a bit more time between changing the CVARs via the config file and the subsequent read out.

Regards and thanks for the help,
az
__________________
''This calls for a delicate blend of psychology and extreme violence.'' - Homer Simpson
azrael is offline
BAILOPAN
Join Date: Jan 2004
Old 09-23-2005 , 10:44  
Reply With Quote #16

It shouldn't crash if you've just use an "exec" server command or in plugin_init, because the buffer is re-flushed after plugin_init anyway (I think). PM would know this better than I...
__________________
egg
BAILOPAN is offline
MistaGee
Senior Member
Join Date: Aug 2004
Location: Germany (Fulda)
Old 09-24-2005 , 06:44  
Reply With Quote #17

BTW: Just to make sure the globals are up-to-date everytime you need 'em, you could as well write the get_cvar_*'s into an own function like this:

Code:
void:readcvars(){ get_cvar_*("blah"); ... ... ... }

and call this function in every other function that uses the cvars.


Greetz MGee
__________________
Ich hab nie behauptet dass ich kein Genie bin!
Mumble-Django: A web interface for Mumble
MistaGee is offline
Send a message via ICQ to MistaGee
azrael
Member
Join Date: Jul 2005
Location: Denmark
Old 09-24-2005 , 21:47  
Reply With Quote #18

Thanks for the suggestion, but I don't believe it will be necessary. The server_exec() command that BAILOPAN suggested works like a charm and the only time those values have to be "up to date" is when the plugin is loaded.

/az
__________________
''This calls for a delicate blend of psychology and extreme violence.'' - Homer Simpson
azrael is offline
Reply



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 05:06.


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