plugins/include/console.inc
author Scott Ehlert <ds@alliedmods.net>
Mon Feb 12 09:00:55 2007 +0000 (2007-02-12)
changeset 475 bb11d7eaae0f
parent 473 ca547afaeb13
child 476 4cbe911aa211
permissions -rw-r--r--
Fixed tabs, hopefully...
ds@457
     1
/**
ds@475
     2
 * vim: set ts=4 :
ds@457
     3
 * ===============================================================
ds@457
     4
 * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
ds@457
     5
 * ===============================================================
ds@457
     6
 *
ds@457
     7
 *  This file is part of the SourceMod/SourcePawn SDK.  This file may only be used 
ds@457
     8
 * or modified under the Terms and Conditions of its License Agreement, which is found 
ds@457
     9
 * in LICENSE.txt.  The Terms and Conditions for making SourceMod extensions/plugins 
ds@457
    10
 * may change at any time.  To view the latest information, see:
ds@457
    11
 *   http://www.sourcemod.net/license.php
ds@457
    12
 *
ds@457
    13
 * Version: $Id$
ds@457
    14
 */
ds@457
    15
 
ds@457
    16
#if defined _console_included
ds@457
    17
 #endinput
ds@457
    18
#endif
ds@457
    19
#define _console_included
ds@457
    20
ds@457
    21
/**
ds@457
    22
 * Flags for console commands and console variables
ds@457
    23
 * @note The descriptions for each constant come directly from the Source SDK.
ds@457
    24
 */
ds@475
    25
#define FCVAR_NONE				0		/**< The default, no flags at all */
ds@475
    26
#define FCVAR_UNREGISTERED		(1<<0)	/**< If this is set, don't add to linked list, etc. */
ds@475
    27
#define FCVAR_LAUNCHER			(1<<1)	/**< Defined by launcher. */
ds@475
    28
#define FCVAR_GAMEDLL			(1<<2)	/**< Defined by the game DLL. */
ds@475
    29
#define FCVAR_CLIENTDLL			(1<<3)	/**< Defined by the client DLL. */
ds@475
    30
#define FCVAR_MATERIAL_SYSTEM	(1<<4)	/**< Defined by the material system. */
ds@475
    31
#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. */
ds@475
    32
#define FCVAR_SPONLY			(1<<6)	/**< This cvar cannot be changed by clients connected to a multiplayer server. */
ds@475
    33
#define	FCVAR_ARCHIVE			(1<<7)	/**< Set to cause it to be saved to vars.rc */
ds@475
    34
#define	FCVAR_NOTIFY			(1<<8)	/**< Notifies players when changed. */
ds@475
    35
#define	FCVAR_USERINFO			(1<<9)	/**< Changes the client's info string. */
ds@475
    36
#define FCVAR_PRINTABLEONLY		(1<<10)	/**< This cvar's string cannot contain unprintable characters (e.g., used for player name, etc.) */
ds@475
    37
#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 */
ds@475
    38
#define FCVAR_NEVER_AS_STRING	(1<<12)	/**< Never try to print that cvar. */
ds@475
    39
#define FCVAR_REPLICATED		(1<<13)	/**< Server setting enforced on clients. */
ds@475
    40
#define FCVAR_CHEAT				(1<<14)	/**< Only useable in singleplayer / debug / multiplayer & sv_cheats */
ds@475
    41
#define FCVAR_STUDIORENDER		(1<<15)	/**< Defined by the studiorender system. */
ds@475
    42
#define FCVAR_DEMO				(1<<16)	/**< Record this cvar when starting a demo file. */
ds@475
    43
#define FCVAR_DONTRECORD		(1<<17)	/**< Don't record these command in demo files. */
ds@475
    44
#define FCVAR_PLUGIN			(1<<18)	/**< Defined by a 3rd party plugin. */
ds@475
    45
#define FCVAR_DATACACHE			(1<<19)	/**< Defined by the datacache system. */
ds@475
    46
#define FCVAR_TOOLSYSTEM		(1<<20)	/**< Defined by an IToolSystem library */
ds@475
    47
#define FCVAR_FILESYSTEM		(1<<21)	/**< Defined by the file system. */
ds@475
    48
#define FCVAR_NOT_CONNECTED		(1<<22)	/**< Cvar cannot be changed by a client that is connected to a server. */
ds@475
    49
#define FCVAR_SOUNDSYSTEM		(1<<23)	/**< Defined by the soundsystem library. */
ds@475
    50
#define FCVAR_ARCHIVE_XBOX		(1<<24)	/**< Cvar written to config.cfg on the Xbox. */
ds@475
    51
#define FCVAR_INPUTSYSTEM		(1<<25)	/**< Defined by the inputsystem DLL. */
ds@475
    52
#define FCVAR_NETWORKSYSTEM		(1<<26)	/**< Defined by the network system. */
ds@475
    53
#define FCVAR_VPHYSICS			(1<<27)/**< Defined by vphysics. */
ds@457
    54
ds@457
    55
/**
ds@457
    56
 * Creates a new console variable.
ds@457
    57
 *
ds@475
    58
 * @param name			Name of new convar.
ds@475
    59
 * @param defaultValue	String containing the default value of new convar.
ds@475
    60
 * @param helpText		Optional description of the convar.
ds@475
    61
 * @param flags			Optional bitstream of flags determining how the convar should be handled. (See FCVAR_* constants for more details)
ds@475
    62
 * @param hasMin		Optional boolean that determines if the convar has a minimum value.
ds@475
    63
 * @param min			Minimum floating point value that the convar can have if hasMin is true.
ds@475
    64
 * @param hasMax		Optional boolean that determines if the convar has a maximum value.
ds@475
    65
 * @param max			Maximum floating point value that the convar can have if hasMax is true.
ds@457
    66
 * @return				A handle to the newly created convar. If the convar already exists, INVALID_HANDLE is returned.
ds@475
    67
 * @error				Convar name is blank or is the same as a console command.
ds@457
    68
 */
ds@457
    69
native Handle:CreateConVar(const String:name[], const String:defaultValue[], const String:helpText[]="", flags=0, bool:hasMin=false, Float:min=0.0, bool:hasMax=false, Float:max=0.0);
ds@457
    70
ds@457
    71
/**
ds@457
    72
 * Searches for a console variable.
ds@457
    73
 *
ds@475
    74
 * @param name			Name of convar to find.
ds@475
    75
 * @return				A handle to the convar if it is found. INVALID_HANDLE otherwise.
ds@457
    76
 */
ds@457
    77
native Handle:FindConVar(const String:name[]);
ds@457
    78
ds@457
    79
/**
ds@465
    80
 * Called when a console variable's value is changed.
ds@465
    81
 *
ds@475
    82
 * @param convar		Handle to the convar that was changed.
ds@475
    83
 * @param oldValue		String containing the value of the convar before it was changed.
ds@475
    84
 * @param newValue		String containing the new value of the convar.
ds@465
    85
 * @noreturn
ds@465
    86
 */
ds@465
    87
functag OnConVarChanged public(Handle:convar, const String:oldValue[], const String:newValue[]);
ds@465
    88
ds@465
    89
/**
ds@465
    90
 * Creates a hook for when a console variable's value is changed.
ds@465
    91
 *
ds@475
    92
 * @param convar		Handle to the convar.
ds@475
    93
 * @param callback		An OnConVarChanged function pointer.
ds@465
    94
 * @noreturn
ds@475
    95
 * @error				Invalid or corrupt Handle or invalid callback function.
ds@465
    96
 */
ds@465
    97
native HookConVarChange(Handle:convar, OnConVarChanged:callback);
ds@465
    98
ds@465
    99
/**
ds@465
   100
 * Removes a hook for when a console variable's value is changed.
ds@465
   101
 *
ds@475
   102
 * @param convar		Handle to the convar.
ds@475
   103
 * @param callback		An OnConVarChanged function pointer.
ds@472
   104
 * @noreturn
ds@475
   105
 * @error				Invalid or corrupt Handle, invalid callback function, or no active hook on convar.
ds@465
   106
 */
ds@472
   107
native UnhookConVarChange(Handle:convar, OnConVarChanged:callback);
ds@465
   108
ds@465
   109
/**
ds@457
   110
 * Returns the boolean value of a console variable.
ds@457
   111
 *
ds@475
   112
 * @param convar		Handle to the convar.
ds@475
   113
 * @return				The boolean value of the convar.
ds@475
   114
 * @error				Invalid or corrupt Handle.
ds@457
   115
 */
ds@457
   116
native bool:GetConVarBool(Handle:convar);
ds@457
   117
ds@457
   118
/**
ds@457
   119
 * Sets the boolean value of a console variable.
ds@457
   120
 *
ds@475
   121
 * @param convar		Handle to the convar.
ds@475
   122
 * @param value			New boolean value.
ds@457
   123
 * @noreturn
ds@475
   124
 * @error				Invalid or corrupt Handle.
ds@457
   125
 */
ds@457
   126
native SetConVarBool(Handle:convar, bool:value);
ds@457
   127
ds@457
   128
/**
ds@457
   129
 * Returns the integer value of a console variable.
ds@457
   130
 *
ds@475
   131
 * @param convar		Handle to the convar.
ds@475
   132
 * @return				The integer value of the convar.
ds@475
   133
 * @error				Invalid or corrupt Handle.
ds@457
   134
 */
ds@457
   135
native GetConVarInt(Handle:convar);
ds@457
   136
ds@457
   137
/**
ds@457
   138
 * Sets the integer value of a console variable.
ds@457
   139
 *
ds@475
   140
 * @param convar		Handle to the convar.
ds@475
   141
 * @param value			New integer value.
ds@457
   142
 * @noreturn
ds@475
   143
 * @error				Invalid or corrupt Handle.
ds@457
   144
 */
ds@457
   145
native SetConVarInt(Handle:convar, value);
ds@457
   146
ds@457
   147
/**
ds@457
   148
 * Returns the floating point value of a console variable.
ds@457
   149
 *
ds@475
   150
 * @param convar		Handle to the convar.
ds@475
   151
 * @return				The floating point value of the convar.
ds@475
   152
 * @error				Invalid or corrupt Handle.
ds@457
   153
 */
ds@457
   154
native Float:GetConVarFloat(Handle:convar);
ds@457
   155
ds@457
   156
/**
ds@457
   157
 * Sets the floating point value of a console variable.
ds@457
   158
 *
ds@475
   159
 * @param convar		Handle to the convar.
ds@475
   160
 * @param value			New floating point value.
ds@457
   161
 * @noreturn
ds@475
   162
 * @error				Invalid or corrupt Handle.
ds@457
   163
 */
ds@457
   164
native SetConVarFloat(Handle:convar, Float:value);
ds@457
   165
ds@457
   166
/**
ds@457
   167
 * Retrieves the string value of a console variable.
ds@457
   168
 *
ds@475
   169
 * @param convar		Handle to the convar.
ds@475
   170
 * @param value			Buffer to store the value of the convar.
ds@475
   171
 * @param maxlength		Maximum length of string buffer.
ds@457
   172
 * @noreturn
ds@475
   173
 * @error				Invalid or corrupt Handle.     
ds@457
   174
 */
ds@465
   175
native GetConVarString(Handle:convar, String:value[], maxlength);
ds@457
   176
ds@457
   177
/**
ds@457
   178
 * Sets the string value of a console variable.
ds@457
   179
 *
ds@475
   180
 * @param convar		Handle to the convar.
ds@475
   181
 * @param value			New string value.
ds@457
   182
 * @noreturn
ds@475
   183
 * @error				Invalid or corrupt Handle.
ds@457
   184
 */
ds@457
   185
native SetConVarString(Handle:convar, const String:value[]);
ds@457
   186
ds@457
   187
/**
ds@457
   188
 * Returns the bitstring of flags on a console variable.
ds@457
   189
 *
ds@475
   190
 * @param convar		Handle to the convar.
ds@475
   191
 * @return				A bitstring containing the FCVAR_* flags that are enabled.
ds@475
   192
 * @error				Invalid or corrupt Handle.
ds@457
   193
 */
ds@457
   194
native GetConVarFlags(Handle:convar);
ds@457
   195
ds@457
   196
/**
ds@457
   197
 * Sets the bitstring of flags on a console variable.
ds@457
   198
 *
ds@475
   199
 * @param convar		Handle to the convar.
ds@475
   200
 * @param flags			A bitstring containing the FCVAR_* flags to enable.
ds@457
   201
 * @noreturn
ds@475
   202
 * @error				Invalid or corrupt Handle.
ds@457
   203
 */
ds@457
   204
native SetConVarFlags(Handle:convar, flags);
ds@457
   205
ds@457
   206
/**
ds@465
   207
 * Retrieves the name of a console variable.
ds@465
   208
 *
ds@475
   209
 * @param convar		Handle to the convar.
ds@475
   210
 * @param value			Buffer to store the name of the convar.
ds@475
   211
 * @param maxlength		Maximum length of string buffer.
ds@465
   212
 * @noreturn
ds@475
   213
 * @error				Invalid or corrupt Handle.     
ds@465
   214
 */
ds@465
   215
native GetConVarName(Handle:convar, const String:name[], maxlength);
ds@465
   216
ds@465
   217
/**
ds@457
   218
 * Retrieves the minimum floating point value that a console variable can contain.
ds@457
   219
 *
ds@475
   220
 * @param convar		Handle to the convar.
ds@475
   221
 * @param min			By-reference cell to store the minimum floating point value.
ds@475
   222
 * @return				True if the convar has a minimum value set, false otherwise.
ds@475
   223
 * @error				Invalid or corrupt Handle.
ds@457
   224
 */
ds@457
   225
native bool:GetConVarMin(Handle:convar, &Float:min);
ds@457
   226
ds@457
   227
/**
ds@457
   228
 * Retrieves the maximum floating point value that a console variable can contain.
ds@457
   229
 *
ds@475
   230
 * @param convar		Handle to the convar.
ds@475
   231
 * @param min			By-reference cell to store the maximum floating point value.
ds@475
   232
 * @return				True if the convar has a maximum value set, false otherwise.
ds@475
   233
 * @error				Invalid or corrupt Handle.
ds@457
   234
 */
ds@457
   235
native bool:GetConVarMax(Handle:convar, &Float:max);
ds@457
   236
ds@457
   237
/**
ds@457
   238
 * Resets the console variable to its default value.
ds@457
   239
 *
ds@475
   240
 * @param convar		Handle to the convar.
ds@457
   241
 * @noreturn
ds@475
   242
 * @error				Invalid or corrupt Handle.
ds@457
   243
 */
ds@457
   244
native ResetConVar(Handle:convar);