AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   PCvars (https://forums.alliedmods.net/showthread.php?t=77784)

Dores 09-20-2008 16:37

PCvars
 
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...

zwfgdlc 09-20-2008 16:41

Re: PCvars
 
http://wiki.amxmodx.org/AMX_Mod_X_1....#CVAR_Pointers

Dores 09-20-2008 17:00

Re: PCvars
 
OK, then i'll stick with pcvar1 = register_cvar("...", "...").
Thanks and +karma...

Arkshine 09-20-2008 17:04

Re: PCvars
 
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_*().

Dores 09-21-2008 09:57

Re: PCvars
 
Quote:

Originally Posted by arkshine (Post 688664)
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. :D Thanks.:up:


All times are GMT -4. The time now is 18:56.

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