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

sm_cvar's sourcecode


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dragonshadow
BANNED
Join Date: Jun 2008
Old 07-06-2009 , 09:46   sm_cvar's sourcecode
Reply With Quote #1

I've looked through all the sp files, the inc files, etc, and I can't find its source code to see how it works.

Anyone know where it is?
Dragonshadow is offline
Greyscale
SourceMod Plugin Approver
Join Date: Dec 2007
Location: strYoMommasHouse[you];
Old 07-06-2009 , 16:29   Re: sm_cvar's sourcecode
Reply With Quote #2

It's just a wrapper around SetConVarString.

Uses FindConVar on the entered cvar, if it returns INVALID_HANDLE it says "couldn't find cvar" and then set's it to the value SetConVarString and replys to the command if it found the cvar.
__________________
Greyscale is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 07-06-2009 , 18:27   Re: sm_cvar's sourcecode
Reply With Quote #3

If you want to know how SetConVarString works you'll have to look at the C++ source code, which is available on http://hg.alliedmods.net.
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.
DJ Tsunami is offline
Dragonshadow
BANNED
Join Date: Jun 2008
Old 07-06-2009 , 20:33   Re: sm_cvar's sourcecode
Reply With Quote #4

I don't understand c++ one bit xD
but thanks, I just wanted to know how it worked so I could manually set cvars through a plugin without it notifying on every cvar.
Dragonshadow is offline
Greyscale
SourceMod Plugin Approver
Join Date: Dec 2007
Location: strYoMommasHouse[you];
Old 07-06-2009 , 20:52   Re: sm_cvar's sourcecode
Reply With Quote #5

In that case you're looking for:

Code:
/**
 * @section Flags for console commands and console variables.  The descriptions 
 * for each constant come directly from the Source SDK.
 */
#define FCVAR_NONE				0		/**< The default, no flags at all */
#define FCVAR_UNREGISTERED		(1<<0)	/**< If this is set, don't add to linked list, etc. */
#define FCVAR_LAUNCHER			(1<<1)	/**< Defined by launcher. */
#define FCVAR_GAMEDLL			(1<<2)	/**< Defined by the game DLL. */
#define FCVAR_CLIENTDLL			(1<<3)	/**< Defined by the client DLL. */
#define FCVAR_MATERIAL_SYSTEM	(1<<4)	/**< Defined by the material system. */
#define FCVAR_PROTECTED			(1<<5)	/**< It's a server cvar, but we don't send the data since it's a password, etc. Sends 1 if it's not bland/zero, 0 otherwise as value. */
#define FCVAR_SPONLY			(1<<6)	/**< This cvar cannot be changed by clients connected to a multiplayer server. */
#define	FCVAR_ARCHIVE			(1<<7)	/**< Set to cause it to be saved to vars.rc */
#define	FCVAR_NOTIFY			(1<<8)	/**< Notifies players when changed. */
#define	FCVAR_USERINFO			(1<<9)	/**< Changes the client's info string. */
#define FCVAR_PRINTABLEONLY		(1<<10)	/**< This cvar's string cannot contain unprintable characters (e.g., used for player name, etc.) */
#define FCVAR_UNLOGGED			(1<<11)	/**< If this is a FCVAR_SERVER, don't log changes to the log file / console if we are creating a log */
#define FCVAR_NEVER_AS_STRING	(1<<12)	/**< Never try to print that cvar. */
#define FCVAR_REPLICATED		(1<<13)	/**< Server setting enforced on clients. */
#define FCVAR_CHEAT				(1<<14)	/**< Only useable in singleplayer / debug / multiplayer & sv_cheats */
#define FCVAR_STUDIORENDER		(1<<15)	/**< Defined by the studiorender system. */
#define FCVAR_DEMO				(1<<16)	/**< Record this cvar when starting a demo file. */
#define FCVAR_DONTRECORD		(1<<17)	/**< Don't record these command in demo files. */
#define FCVAR_PLUGIN			(1<<18)	/**< Defined by a 3rd party plugin. */
#define FCVAR_DATACACHE			(1<<19)	/**< Defined by the datacache system. */
#define FCVAR_TOOLSYSTEM		(1<<20)	/**< Defined by an IToolSystem library */
#define FCVAR_FILESYSTEM		(1<<21)	/**< Defined by the file system. */
#define FCVAR_NOT_CONNECTED		(1<<22)	/**< Cvar cannot be changed by a client that is connected to a server. */
#define FCVAR_SOUNDSYSTEM		(1<<23)	/**< Defined by the soundsystem library. */
#define FCVAR_ARCHIVE_XBOX		(1<<24)	/**< Cvar written to config.cfg on the Xbox. */
#define FCVAR_INPUTSYSTEM		(1<<25)	/**< Defined by the inputsystem DLL. */
#define FCVAR_NETWORKSYSTEM		(1<<26)	/**< Defined by the network system. */
#define FCVAR_VPHYSICS			(1<<27)	/**< Defined by vphysics. */

/**
 * Returns the bitstring of flags on a console variable.
 *
 * @param convar		Handle to the convar.
 * @return				A bitstring containing the FCVAR_* flags that are enabled.
 * @error				Invalid or corrupt Handle.
 */
native GetConVarFlags(Handle:convar);

/**
 * Sets the bitstring of flags on a console variable.
 *
 * @param convar		Handle to the convar.
 * @param flags			A bitstring containing the FCVAR_* flags to enable.
 * @noreturn
 * @error				Invalid or corrupt Handle.
 */
native SetConVarFlags(Handle:convar, flags);
Ex:
Code:
new cvarflags = GetConVarFlags(MYCVARHANDLE);  Get the handle of a named cvar with FindConVar, or if it's your own cvar you should store the handle in a global variable.
cvarflags |= ~FCVAR_NOTIFY;  // To be honest, I'm not sure if this is right, can someone verify?  I suck with bitwise operations.
SetConVarFlags(MYCVARHANDLE, cvarflags); // Reset the flags
__________________
Greyscale is offline
J-Factor
Junior Member
Join Date: Jul 2009
Old 07-07-2009 , 07:46   Re: sm_cvar's sourcecode
Reply With Quote #6

Quote:
Originally Posted by Greyscale View Post
Code:
cvarflags |= ~FCVAR_NOTIFY;  // To be honest, I'm not sure if this is right, can someone verify?  I suck with bitwise operations.
It should be:

Code:
cvarflags &= ~FCVAR_NOTIFY;
If you want to turn something on, use an OR mask (|=).

If you want to turn something off, use an AND mask (&=).
J-Factor 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:13.


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