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

register_cvar() and get_pcvar_num()


Post New Thread Reply   
 
Thread Tools Display Modes
hypheni
Senior Member
Join Date: Jul 2011
Location: India
Old 01-14-2013 , 12:38   Re: register_cvar() and get_pcvar_num()
Reply With Quote #11

I created my own cfg and executed that in plugin_cfg and then read those cvars. Still same. Getting false value.

PHP Code:
    server_cmd("exec addons/amxmodx/configs/amx_customs.cfg")
    
server_cmd("echo >>>Money: %s"get_pcvar_num(amx_money)) 
Output >>>Money:

Where amx_money is set to 5000 in amx_customs.cfg
hypheni is offline
Send a message via Skype™ to hypheni
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 01-14-2013 , 14:00   Re: register_cvar() and get_pcvar_num()
Reply With Quote #12

IIRC some cvars are unable to change from the original registered value on the first map the server loads. Try changing the map once after the server loads and see if you get the same results.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-14-2013 , 16:49   Re: register_cvar() and get_pcvar_num()
Reply With Quote #13

As alternative method and if you don't mind third party module, you can use Cvar Utilities and hooking the cvar value change easily. It will work all the time.

Fast example :

Code:
#include <amxmodx> #include <cvar_util> public plugin_init() {     register_plugin( "", "", "" );         CvarHookChange( register_cvar( "amx_showads", "1" ), "OnCvarChange" ); } public OnCvarChange( const handleCvar, const oldValue[], const newValue[], const cvarName[] ) {     if( newValue[0] == '1' )     {         config();     } } config() {     log_amx( "Do stuffs here, called here only when activated" ); }
__________________
Arkshine is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-14-2013 , 20:01   Re: register_cvar() and get_pcvar_num()
Reply With Quote #14

hypheni, attach your plugin to your next post (as an attachment) so we can actually see what is going on and possibly test it. Also, attach the file that you are reading from.

Quote:
Originally Posted by Emp` View Post
IIRC some cvars are unable to change from the original registered value on the first map the server loads.
I never heard of issues like this before and I find it hard to believe. Not saying it's not possible that your statement is correct but I imagine it would have been a huge issue if it really happened that way.
__________________
fysiks is offline
hypheni
Senior Member
Join Date: Jul 2011
Location: India
Old 01-18-2013 , 23:04   Re: register_cvar() and get_pcvar_num()
Reply With Quote #15

After a few busy days Im back to amx. I have attached the sma. I was trying to get amx_showads value.
Attached Files
File Type: sma Get Plugin or Get Source (amx_customs.sma - 623 views - 19.2 KB)

Last edited by hypheni; 01-18-2013 at 23:05.
hypheni is offline
Send a message via Skype™ to hypheni
hypheni
Senior Member
Join Date: Jul 2011
Location: India
Old 01-24-2013 , 03:01   Re: register_cvar() and get_pcvar_num()
Reply With Quote #16

Anyone tried to compile the above. What is the issue ?
hypheni is offline
Send a message via Skype™ to hypheni
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 06:15.


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