Raised This Month: $32 Target: $400
 8% 

cvar help.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hamza47sohail
Senior Member
Join Date: Jan 2014
Old 04-11-2014 , 09:14   cvar help.
Reply With Quote #1

I want to have something where the codes checks for a cvar and only than uses the code below.

so lets say something like this

if cvar: code_1: execute
{
code here
}
if disabled, execute nothing

if cvar: code_2: execute
{
code here
}
if disabled, execute nothing

Excuse my syntax as I am a total green horn at coding.
hamza47sohail is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 04-11-2014 , 09:29   Re: cvar help.
Reply With Quote #2

So, something like

PHP Code:
if (GetConVarBool(g_Cvar_Handle))
{

Of course, to get the cvar handle you have to either call CreateConVar (to create a new one, should be done in OnPluginStart) or FindConVar (to get a handle to an existing one, will return INVALID_HANDLE if not found, should be called in OnAllPluginsLoaded).

FindConVar is a somewhat expensive operation, so you should cache the results.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 04-11-2014 at 09:32.
Powerlord is offline
hamza47sohail
Senior Member
Join Date: Jan 2014
Old 04-12-2014 , 14:37   Re: cvar help.
Reply With Quote #3

Quote:
Originally Posted by Powerlord View Post
So, something like

PHP Code:
if (GetConVarBool(g_Cvar_Handle))
{

Of course, to get the cvar handle you have to either call CreateConVar (to create a new one, should be done in OnPluginStart) or FindConVar (to get a handle to an existing one, will return INVALID_HANDLE if not found, should be called in OnAllPluginsLoaded).

FindConVar is a somewhat expensive operation, so you should cache the results.
Thanks
hamza47sohail is offline
Reply


Thread Tools
Display Modes

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:39.


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