[INFO] Cvars
CVARs
This quick guide will show you what they are and how they behave. Here's a great list of cvars: http://scripting.elxdraco.net/cvarlist/ What are they? You can think of them as global (sort of) variables. You can retrieve their values, set new values, and also create new cvars. They differ from actual global variables, because you can change cvar values from the console. Usage You can store all sorts of stuff in your cvars. Typically, they are used to control plugins, turn them on/off, or to hold data temporarily. You can use the flags listed below to modify the behavior of the cvars. If you will read the cvar value later on in your script, use pointers. Use get_pcvar_flags, get_pcvar_float, get_pcvar_num, or get_pcvar_string. Do not use get_cvar_flags, get_cvar_float, get_cvar_num, or get_cvar_string. Code:
I haven't found any examples where fvalue is used, so please post if you know what it's for. Example Usage: Code:
How do they behave? Code:
Order of Events: When you do register_cvar("cvar_name", "cvar_value"), you are attempting to create a new cvar with a new default value. If this cvar already exists, this function will not overwrite the original value. Instead, it will return a pointer to the existing cvar that you can later access with get_pcvar_flags, get_pcvar_float, get_pcvar_num, or get_pcvar_string. To get a pointer for a cvar, use get_cvar_pointer("cvarname"). CVAR flags This is taken directly from amxconst.inc: FCVAR_ARCHIVE set to cause it to be saved to vars.rc FCVAR_USERINFO changes the client's info string FCVAR_SERVER notifies players when changed FCVAR_EXTDLL defined by external DLL FCVAR_CLIENTDLL defined by the client dll FCVAR_PROTECTED 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 FCVAR_SPONLY This cvar cannot be changed by clients connected to a multiplayer server. FCVAR_PRINTABLEONLY This cvar's string cannot contain unprintable characters ( e.g., used for player name etc ). FCVAR_UNLOGGED If this is a FCVAR_SERVER, don't log changes to the log file / console if we are creating a log Unfortunately, I can't find any examples for the following flags: FCVAR_ARCHIVE, FCVAR_USERINFO, FCVAR_EXTDLL, FCVAR_CLIENTDLL. So, I'd like to ask anyone who knows about these flags to post. Example Here's a simple script that counts how many times a server stops running. If you can understand how this script works, then you probably have a good grip on cvars. This script should only be used as a demonstration to understand cvars. If you really want to count crashes accurately, I would recommend a different method. Let me know if you're interested. Code:
|
Re: [INFO] Cvars
Nice guide! :)
i'm interested in this Quote:
|
Re: [INFO] Cvars
To avoid creating many variables for cvars, you can do like this:
PHP Code:
|
Re: [INFO] Cvars
That doesn't really help unless you cache the strings as a series of arrays, too. Then you can loop through each cvar.
|
Re: [INFO] Cvars
PHP Code:
|
Re: [INFO] Cvars
good work bro
|
All times are GMT -4. The time now is 22:29. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.