Raised This Month: $ Target: $400
 0% 

better way to declare CVARs


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 07-14-2011 , 14:59   Re: better way to declare CVARs
Reply With Quote #1

Quote:
Originally Posted by gamer99 View Post
Hi ,

Suppose I have a CVAR

g_dTest = register_cvar("test","1")

Now g_dTest I have declared globaly . Suppose I need to use the value of
the cvar within one function with is being called every 1 sec. So i wrote

new iTest = get_pcvar_num(g_dTest) inside the function .
But with this get_pcvar_num is being called also every time .

Can we do like
1)declaring iTest globally and then calling one function which will set the value of iTest globally ?

Is there any disadvantage in this ?or what is the better way of declaring one cvar ?
Quote:
Originally Posted by gamer99 View Post
init is not working ... i am checking is a client prethink ... And declaring the cvar as global ....

I don wanna any extra module .... better I will check every time in prethink
wait what? originally you were concerned that get_pcvar_num gets called every second, so instead you will call it at EVERY frame
jimaway is offline
gamer99
Senior Member
Join Date: Jul 2011
Old 07-14-2011 , 15:12   Re: better way to declare CVARs
Reply With Quote #2

sry for the one second confudion .. the should be one frame .. ..

I was trying to avoid that calling every frame ...
gamer99 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-14-2011 , 15:17   Re: better way to declare CVARs
Reply With Quote #3

Something like this:

PHP Code:
new g_pCvar
new g_iCvarValue

// plugin_init()
    
g_pCvar register_cvar("mycvar""1")

// plugin_cfg() // You can use any recurring function here like new round or round end or whatever
    
g_iCvarValue get_pcvar_num(g_pCvar)

// client_prethink()
    
if( g_iCvarValue == )
    
// ...  Use it how ever you need here. 
__________________
fysiks is offline
gamer99
Senior Member
Join Date: Jul 2011
Old 07-14-2011 , 15:43   Re: better way to declare CVARs
Reply With Quote #4

superb idea fysiks and bibu ... love u man
gamer99 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 01:07.


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