Raised This Month: $ Target: $400
 0% 

PCvars


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 09-20-2008 , 16:37   PCvars
Reply With Quote #1

Stupid question:
I saw scripts that set the variable's value to the cvar's value at plugin_init(), without setting it using the register_cvar.
I.E:
PHP Code:
new pcvar1pcvar2pcvar3pcvar4;
public 
plugin_init(){

     
register_cvar("OMG_IM_A_CVAR""1337");
     
register_cvar("dor123_is_such_a_newbie""0");
     
register_cvar("haha_cvars_funny_word""12");
     
register_cvar("woot_cvars_everywhere""50");

     
pcvar1 get_cvar_num("OMG_IM_A_CVAR");
     
pcvar2 get_cvar_num("dor123_is_such_a_newbie");
     
pcvar3 get_cvar_num("haha_cvars_funny_word");
     
pcvar4 get_cvar_num("woot_cvars_everywhere");

     
// instead of:

     
pcvar1 register_cvar("OMG_IM_A_CVAR""1337");
     
// etc...

What I wondered was if it only registers the variable's value at the plugin initial, will it be changed when the cvar itself changed? For example: cvar "hello_world" is set to "1". Admin changes it to "2". will pcvar (pcvar = get_cvar_num("hello_world")) be changed to 2 as well at the rest of the plugin? Or will it stay the original cvar's value because it's at plugin_init?
Hope you understand what I mean...
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores is offline
zwfgdlc
Senior Member
Join Date: May 2006
Old 09-20-2008 , 16:41   Re: PCvars
Reply With Quote #2

http://wiki.amxmodx.org/AMX_Mod_X_1....#CVAR_Pointers
zwfgdlc is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 09-20-2008 , 17:00   Re: PCvars
Reply With Quote #3

OK, then i'll stick with pcvar1 = register_cvar("...", "...").
Thanks and +karma...
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ

Last edited by Dores; 09-20-2008 at 17:02.
Dores is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 09-20-2008 , 17:04   Re: PCvars
Reply With Quote #4

get_cvar_pointer() is used for cvar which is not in your plugin.

new pointer = get_cvar_pointer( "amx_other_cvars" )

And to retrieve the value, use get_pcvar_*().
__________________
Arkshine is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 09-21-2008 , 09:57   Re: PCvars
Reply With Quote #5

Quote:
Originally Posted by arkshine View Post
get_cvar_pointer() is used for cvar which is not in your plugin.

new pointer = get_cvar_pointer( "amx_other_cvars" )

And to retrieve the value, use get_pcvar_*().
Yeah I know I just wanted to make sure. Thanks.
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores 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 12:35.


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