1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/plugins/include/console.inc Sun Mar 30 07:00:22 2008 +0000
1.3 @@ -0,0 +1,771 @@
1.4 +/**
1.5 + * vim: set ts=4 :
1.6 + * =============================================================================
1.7 + * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
1.8 + * =============================================================================
1.9 + *
1.10 + * This file is part of the SourceMod/SourcePawn SDK.
1.11 + *
1.12 + * This program is free software; you can redistribute it and/or modify it under
1.13 + * the terms of the GNU General Public License, version 3.0, as published by the
1.14 + * Free Software Foundation.
1.15 + *
1.16 + * This program is distributed in the hope that it will be useful, but WITHOUT
1.17 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1.18 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
1.19 + * details.
1.20 + *
1.21 + * You should have received a copy of the GNU General Public License along with
1.22 + * this program. If not, see <http://www.gnu.org/licenses/>.
1.23 + *
1.24 + * As a special exception, AlliedModders LLC gives you permission to link the
1.25 + * code of this program (as well as its derivative works) to "Half-Life 2," the
1.26 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
1.27 + * by the Valve Corporation. You must obey the GNU General Public License in
1.28 + * all respects for all other code used. Additionally, AlliedModders LLC grants
1.29 + * this exception to all derivative works. AlliedModders LLC defines further
1.30 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
1.31 + * or <http://www.sourcemod.net/license.php>.
1.32 + *
1.33 + * Version: $Id$
1.34 + */
1.35 +
1.36 +#if defined _console_included
1.37 + #endinput
1.38 +#endif
1.39 +#define _console_included
1.40 +
1.41 +#define INVALID_FCVAR_FLAGS (-1)
1.42 +
1.43 +/**
1.44 + * Console variable bound values used with Get/SetConVarBounds()
1.45 + */
1.46 +enum ConVarBounds
1.47 +{
1.48 + ConVarBound_Upper = 0,
1.49 + ConVarBound_Lower
1.50 +};
1.51 +
1.52 +/**
1.53 + * Console variable query helper values.
1.54 + */
1.55 +enum QueryCookie
1.56 +{
1.57 + QUERYCOOKIE_FAILED = 0,
1.58 +};
1.59 +
1.60 +/**
1.61 + * Reply sources for commands.
1.62 + */
1.63 +enum ReplySource
1.64 +{
1.65 + SM_REPLY_TO_CONSOLE = 0,
1.66 + SM_REPLY_TO_CHAT = 1,
1.67 +};
1.68 +
1.69 +/**
1.70 + * Console variable query result values.
1.71 + */
1.72 +enum ConVarQueryResult
1.73 +{
1.74 + ConVarQuery_Okay = 0, /**< Retrieval of client convar value was successful. */
1.75 + ConVarQuery_NotFound, /**< Client convar was not found. */
1.76 + ConVarQuery_NotValid, /**< A console command with the same name was found, but there is no convar. */
1.77 + ConVarQuery_Protected /**< Client convar was found, but it is protected. The server cannot retrieve its value. */
1.78 +};
1.79 +
1.80 +/**
1.81 + * @section Flags for console commands and console variables. The descriptions
1.82 + * for each constant come directly from the Source SDK.
1.83 + */
1.84 +#define FCVAR_NONE 0 /**< The default, no flags at all */
1.85 +#define FCVAR_UNREGISTERED (1<<0) /**< If this is set, don't add to linked list, etc. */
1.86 +#define FCVAR_LAUNCHER (1<<1) /**< Defined by launcher. */
1.87 +#define FCVAR_GAMEDLL (1<<2) /**< Defined by the game DLL. */
1.88 +#define FCVAR_CLIENTDLL (1<<3) /**< Defined by the client DLL. */
1.89 +#define FCVAR_MATERIAL_SYSTEM (1<<4) /**< Defined by the material system. */
1.90 +#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. */
1.91 +#define FCVAR_SPONLY (1<<6) /**< This cvar cannot be changed by clients connected to a multiplayer server. */
1.92 +#define FCVAR_ARCHIVE (1<<7) /**< Set to cause it to be saved to vars.rc */
1.93 +#define FCVAR_NOTIFY (1<<8) /**< Notifies players when changed. */
1.94 +#define FCVAR_USERINFO (1<<9) /**< Changes the client's info string. */
1.95 +#define FCVAR_PRINTABLEONLY (1<<10) /**< This cvar's string cannot contain unprintable characters (e.g., used for player name, etc.) */
1.96 +#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 */
1.97 +#define FCVAR_NEVER_AS_STRING (1<<12) /**< Never try to print that cvar. */
1.98 +#define FCVAR_REPLICATED (1<<13) /**< Server setting enforced on clients. */
1.99 +#define FCVAR_CHEAT (1<<14) /**< Only useable in singleplayer / debug / multiplayer & sv_cheats */
1.100 +#define FCVAR_STUDIORENDER (1<<15) /**< Defined by the studiorender system. */
1.101 +#define FCVAR_DEMO (1<<16) /**< Record this cvar when starting a demo file. */
1.102 +#define FCVAR_DONTRECORD (1<<17) /**< Don't record these command in demo files. */
1.103 +#define FCVAR_PLUGIN (1<<18) /**< Defined by a 3rd party plugin. */
1.104 +#define FCVAR_DATACACHE (1<<19) /**< Defined by the datacache system. */
1.105 +#define FCVAR_TOOLSYSTEM (1<<20) /**< Defined by an IToolSystem library */
1.106 +#define FCVAR_FILESYSTEM (1<<21) /**< Defined by the file system. */
1.107 +#define FCVAR_NOT_CONNECTED (1<<22) /**< Cvar cannot be changed by a client that is connected to a server. */
1.108 +#define FCVAR_SOUNDSYSTEM (1<<23) /**< Defined by the soundsystem library. */
1.109 +#define FCVAR_ARCHIVE_XBOX (1<<24) /**< Cvar written to config.cfg on the Xbox. */
1.110 +#define FCVAR_INPUTSYSTEM (1<<25) /**< Defined by the inputsystem DLL. */
1.111 +#define FCVAR_NETWORKSYSTEM (1<<26) /**< Defined by the network system. */
1.112 +#define FCVAR_VPHYSICS (1<<27) /**< Defined by vphysics. */
1.113 +
1.114 +/**
1.115 + * @endsection
1.116 + */
1.117 +
1.118 +/**
1.119 + * Executes a server command as if it were on the server console (or RCON)
1.120 + *
1.121 + * @param format Formatting rules.
1.122 + * @param ... Variable number of format parameters.
1.123 + * @noreturn
1.124 + */
1.125 +native ServerCommand(const String:format[], any:...);
1.126 +
1.127 +/**
1.128 + * Inserts a server command at the beginning of the server command buffer.
1.129 + *
1.130 + * @param format Formatting rules.
1.131 + * @param ... Variable number of format parameters.
1.132 + * @noreturn
1.133 + */
1.134 +native InsertServerCommand(const String:format[], any:...);
1.135 +
1.136 +/**
1.137 + * Executes every command in the server's command buffer, rather than once per frame.
1.138 + *
1.139 + * @noreturn
1.140 + */
1.141 +native ServerExecute();
1.142 +
1.143 +/**
1.144 + * Executes a client command. Note that this will not work on clients unless
1.145 + * they have cl_restrict_server_commands set to 0.
1.146 + *
1.147 + * @param client Index of the client.
1.148 + * @param fmt Format of the client command.
1.149 + * @param ... Format parameters/
1.150 + * @noreturn
1.151 + * @error Invalid client index, or client not connected.
1.152 + */
1.153 +native ClientCommand(client, const String:fmt[], any:...);
1.154 +
1.155 +/**
1.156 + * Executes a client command on the server without being networked.
1.157 + *
1.158 + * FakeClientCommand() overwrites the command tokenization buffer. This can
1.159 + * cause undesired effects because future calls to GetCmdArg* will return
1.160 + * data from the FakeClientCommand(), not the parent command. If you are in
1.161 + * a hook where this matters (for example, a "say" hook), you should use
1.162 + * FakeClientCommandEx() instead.
1.163 + *
1.164 + * @param client Index of the client.
1.165 + * @param fmt Format of the client command.
1.166 + * @param ... Format parameters
1.167 + * @noreturn
1.168 + * @error Invalid client index, or client not connected.
1.169 + */
1.170 +native FakeClientCommand(client, const String:fmt[], any:...);
1.171 +
1.172 +/**
1.173 + * Executes a client command on the server without being networked. The
1.174 + * execution of the client command is delayed by one frame to prevent any
1.175 + * re-entrancy issues that might surface with FakeClientCommand().
1.176 + *
1.177 + * @param client Index of the client.
1.178 + * @param fmt Format of the client command.
1.179 + * @param ... Format parameters
1.180 + * @noreturn
1.181 + * @error Invalid client index, or client not connected.
1.182 + */
1.183 +native FakeClientCommandEx(client, const String:fmt[], any:...);
1.184 +
1.185 +/**
1.186 + * Sends a message to the server console.
1.187 + *
1.188 + * @param format Formatting rules.
1.189 + * @param ... Variable number of format parameters.
1.190 + * @noreturn
1.191 + */
1.192 +native PrintToServer(const String:format[], any:...);
1.193 +
1.194 +/**
1.195 + * Sends a message to a client's console.
1.196 + *
1.197 + * @param client Client index.
1.198 + * @param format Formatting rules.
1.199 + * @param ... Variable number of format parameters.
1.200 + * @noreturn
1.201 + * @error If the client is not connected an error will be thrown.
1.202 + */
1.203 +native PrintToConsole(client, const String:format[], any:...);
1.204 +
1.205 +/**
1.206 + * Reples to a message in a command.
1.207 + *
1.208 + * A client index of 0 will use PrintToServer().
1.209 + * If the command was from the console, PrintToConsole() is used.
1.210 + * If the command was from chat, PrintToChat() is used.
1.211 + *
1.212 + * @param client Client index, or 0 for server.
1.213 + * @param format Formatting rules.
1.214 + * @param ... Variable number of format parameters.
1.215 + * @noreturn
1.216 + * @error If the client is not connected or invalid.
1.217 + */
1.218 +native ReplyToCommand(client, const String:format[], any:...);
1.219 +
1.220 +/**
1.221 + * Returns the current reply source of a command.
1.222 + *
1.223 + * @return ReplySource value.
1.224 + */
1.225 +native ReplySource:GetCmdReplySource();
1.226 +
1.227 +/**
1.228 + * Sets the current reply source of a command.
1.229 + *
1.230 + * Only use this if you know what you are doing. You should save the old value
1.231 + * and restore it once you are done.
1.232 + *
1.233 + * @param source New ReplySource value.
1.234 + * @return Old ReplySource value.
1.235 + */
1.236 +native ReplySource:SetCmdReplySource(ReplySource:source);
1.237 +
1.238 +/**
1.239 + * Returns whether the current say hook is a chat trigger.
1.240 + *
1.241 + * This function is only meaningful inside say or say_team hooks.
1.242 + *
1.243 + * @return True if a chat trigger, false otherwise.
1.244 + */
1.245 +native bool:IsChatTrigger();
1.246 +
1.247 +/**
1.248 + * Displays usage of an admin command to users depending on the
1.249 + * setting of the sm_show_activity cvar. All users receive a message
1.250 + * in their chat text, except for the originating client, who receives
1.251 + * the message based on the current ReplySource.
1.252 + *
1.253 + * @param client Client index doing the action, or 0 for server.
1.254 + * @param tag Tag to prepend to the message.
1.255 + * @param format Formatting rules.
1.256 + * @param ... Variable number of format parameters.
1.257 + * @noreturn
1.258 + * @error
1.259 + */
1.260 +native ShowActivity2(client, const String:tag[], const String:format[], any:...);
1.261 +
1.262 +/**
1.263 + * Displays usage of an admin command to users depending on the
1.264 + * setting of the sm_show_activity cvar.
1.265 + *
1.266 + * This version does not display a message to the originating client
1.267 + * if used from chat triggers or menus. If manual replies are used
1.268 + * for these cases, then this function will suffice. Otherwise,
1.269 + * ShowActivity2() is slightly more useful.
1.270 + *
1.271 + * @param client Client index doing the action, or 0 for server.
1.272 + * @param format Formatting rules.
1.273 + * @param ... Variable number of format parameters.
1.274 + * @noreturn
1.275 + * @error
1.276 + */
1.277 +native ShowActivity(client, const String:format[], any:...);
1.278 +
1.279 +/**
1.280 + * Same as ShowActivity(), except the tag parameter is used instead of
1.281 + * "[SM] " (note that you must supply any spacing).
1.282 + *
1.283 + * @param client Client index doing the action, or 0 for server.
1.284 + * @param tag Tag to display with.
1.285 + * @param format Formatting rules.
1.286 + * @param ... Variable number of format parameters.
1.287 + * @noreturn
1.288 + * @error
1.289 + */
1.290 +native ShowActivityEx(client, const String:tag[], const String:format[], any:...);
1.291 +
1.292 +/**
1.293 + * Called when a server-only command is invoked.
1.294 + *
1.295 + * @params args Number of arguments that were in the argument string.
1.296 + * @return An Action value. Not handling the command
1.297 + * means that Source will report it as "not found."
1.298 + */
1.299 +functag SrvCmd Action:public(args);
1.300 +
1.301 +/**
1.302 + * Creates a server-only console command, or hooks an already existing one.
1.303 + *
1.304 + * @param cmd Name of the command to hook or create.
1.305 + * @param callback A function to use as a callback for when the command is invoked.
1.306 + * @param description Optional description to use for command creation.
1.307 + * @param flags Optional flags to use for command creation.
1.308 + * @noreturn
1.309 + * @error Command name is the same as an existing convar.
1.310 + */
1.311 +native RegServerCmd(const String:cmd[], SrvCmd:callback, const String:description[]="", flags=0);
1.312 +
1.313 +/**
1.314 + * Called when a generic console command is invoked.
1.315 + *
1.316 + * @param client Index of the client, or 0 from the server.
1.317 + * @param args Number of arguments that were in the argument string.
1.318 + * @return An Action value. Not handling the command
1.319 + * means that Source will report it as "not found."
1.320 + */
1.321 +functag ConCmd Action:public(client, args);
1.322 +
1.323 +/**
1.324 + * Creates a console command, or hooks an already existing one.
1.325 + *
1.326 + * @param cmd Name of the command to hook or create.
1.327 + * @param callback A function to use as a callback for when the command is invoked.
1.328 + * @param description Optional description to use for command creation.
1.329 + * @param flags Optional flags to use for command creation.
1.330 + * @noreturn
1.331 + * @error Command name is the same as an existing convar.
1.332 + */
1.333 +native RegConsoleCmd(const String:cmd[], ConCmd:callback, const String:description[]="", flags=0);
1.334 +
1.335 +/**
1.336 + * Creates a console command as an administrative command. If the command does not exist,
1.337 + * it is created. When this command is invoked, the access rights of the player are
1.338 + * automatically checked before allowing it to continue.
1.339 + *
1.340 + * @param cmd String containing command to register.
1.341 + * @param callback A function to use as a callback for when the command is invoked.
1.342 + * @param adminflags Administrative flags (bitstring) to use for permissions.
1.343 + * @param group String containing the command group to use. If empty,
1.344 + * the plugin's filename will be used instead.
1.345 + * @param description Optional description to use for help.
1.346 + * @param flags Optional console flags.
1.347 + * @noreturn
1.348 + * @error Command name is the same as an existing convar.
1.349 + */
1.350 +native RegAdminCmd(const String:cmd[],
1.351 + ConCmd:callback,
1.352 + adminflags,
1.353 + const String:description[]="",
1.354 + const String:group[]="",
1.355 + flags=0);
1.356 +
1.357 +/**
1.358 + * Returns the number of arguments from the current console or server command.
1.359 + * @note Unlike the HL2 engine call, this does not include the command itself.
1.360 + *
1.361 + * @return Number of arguments to the current command.
1.362 + */
1.363 +native GetCmdArgs();
1.364 +
1.365 +/**
1.366 + * Retrieves a command argument given its index, from the current console or
1.367 + * server command.
1.368 + * @note Argument indexes start at 1; 0 retrieves the command name.
1.369 + *
1.370 + * @param argnum Argument number to retrieve.
1.371 + * @param buffer Buffer to use for storing the string.
1.372 + * @param maxlength Maximum length of the buffer.
1.373 + * @return Length of string written to buffer.
1.374 + */
1.375 +native GetCmdArg(argnum, String:buffer[], maxlength);
1.376 +
1.377 +/**
1.378 + * Retrieves the entire command argument string in one lump from the current
1.379 + * console or server command.
1.380 + *
1.381 + * @param buffer Buffer to use for storing the string.
1.382 + * @param maxlength Maximum length of the buffer.
1.383 + * @return Length of string written to buffer.
1.384 + */
1.385 +native GetCmdArgString(String:buffer[], maxlength);
1.386 +
1.387 +/**
1.388 + * Creates a new console variable.
1.389 + *
1.390 + * @param name Name of new convar.
1.391 + * @param defaultValue String containing the default value of new convar.
1.392 + * @param description Optional description of the convar.
1.393 + * @param flags Optional bitstring of flags determining how the convar should be handled. See FCVAR_* constants for more details.
1.394 + * @param hasMin Optional boolean that determines if the convar has a minimum value.
1.395 + * @param min Minimum floating point value that the convar can have if hasMin is true.
1.396 + * @param hasMax Optional boolean that determines if the convar has a maximum value.
1.397 + * @param max Maximum floating point value that the convar can have if hasMax is true.
1.398 + * @return A handle to the newly created convar. If the convar already exists, INVALID_HANDLE is returned.
1.399 + * @error Convar name is blank or is the same as an existing console command.
1.400 + */
1.401 +native Handle:CreateConVar(const String:name[], const String:defaultValue[], const String:description[]="", flags=0, bool:hasMin=false, Float:min=0.0, bool:hasMax=false, Float:max=0.0);
1.402 +
1.403 +/**
1.404 + * Searches for a console variable.
1.405 + *
1.406 + * @param name Name of convar to find.
1.407 + * @return A handle to the convar if it is found. INVALID_HANDLE otherwise.
1.408 + */
1.409 +native Handle:FindConVar(const String:name[]);
1.410 +
1.411 +/**
1.412 + * Called when a console variable's value is changed.
1.413 + *
1.414 + * @param convar Handle to the convar that was changed.
1.415 + * @param oldValue String containing the value of the convar before it was changed.
1.416 + * @param newValue String containing the new value of the convar.
1.417 + * @noreturn
1.418 + */
1.419 +functag ConVarChanged public(Handle:convar, const String:oldValue[], const String:newValue[]);
1.420 +
1.421 +/**
1.422 + * Creates a hook for when a console variable's value is changed.
1.423 + *
1.424 + * @param convar Handle to the convar.
1.425 + * @param callback An OnConVarChanged function pointer.
1.426 + * @noreturn
1.427 + * @error Invalid or corrupt Handle or invalid callback function.
1.428 + */
1.429 +native HookConVarChange(Handle:convar, ConVarChanged:callback);
1.430 +
1.431 +/**
1.432 + * Removes a hook for when a console variable's value is changed.
1.433 + *
1.434 + * @param convar Handle to the convar.
1.435 + * @param callback An OnConVarChanged function pointer.
1.436 + * @noreturn
1.437 + * @error Invalid or corrupt Handle, invalid callback function, or no active hook on convar.
1.438 + */
1.439 +native UnhookConVarChange(Handle:convar, ConVarChanged:callback);
1.440 +
1.441 +/**
1.442 + * Returns the boolean value of a console variable.
1.443 + *
1.444 + * @param convar Handle to the convar.
1.445 + * @return The boolean value of the convar.
1.446 + * @error Invalid or corrupt Handle.
1.447 + */
1.448 +native bool:GetConVarBool(Handle:convar);
1.449 +
1.450 +/**
1.451 + * Sets the boolean value of a console variable.
1.452 + *
1.453 + * @param convar Handle to the convar.
1.454 + * @param value New boolean value.
1.455 + * @param replicate If set to true, the new convar value will be set on all clients.
1.456 + * This will only work if the convar has the FCVAR_REPLICATED flag
1.457 + * and actually exists on clients.
1.458 + * @param notify If set to true, clients will be notified that the convar has changed.
1.459 + * This will only work if the convar has the FCVAR_NOTIFY flag.
1.460 + * @noreturn
1.461 + * @error Invalid or corrupt Handle.
1.462 + */
1.463 +native SetConVarBool(Handle:convar, bool:value, bool:replicate=false, bool:notify=false);
1.464 +
1.465 +/**
1.466 + * Returns the integer value of a console variable.
1.467 + *
1.468 + * @param convar Handle to the convar.
1.469 + * @return The integer value of the convar.
1.470 + * @error Invalid or corrupt Handle.
1.471 + */
1.472 +native GetConVarInt(Handle:convar);
1.473 +
1.474 +/**
1.475 + * Sets the integer value of a console variable.
1.476 + *
1.477 + * @param convar Handle to the convar.
1.478 + * @param value New integer value.
1.479 + * @param replicate If set to true, the new convar value will be set on all clients.
1.480 + * This will only work if the convar has the FCVAR_REPLICATED flag
1.481 + * and actually exists on clients.
1.482 + * @param notify If set to true, clients will be notified that the convar has changed.
1.483 + * This will only work if the convar has the FCVAR_NOTIFY flag.
1.484 + * @noreturn
1.485 + * @error Invalid or corrupt Handle.
1.486 + */
1.487 +native SetConVarInt(Handle:convar, value, bool:replicate=false, bool:notify=false);
1.488 +
1.489 +/**
1.490 + * Returns the floating point value of a console variable.
1.491 + *
1.492 + * @param convar Handle to the convar.
1.493 + * @return The floating point value of the convar.
1.494 + * @error Invalid or corrupt Handle.
1.495 + */
1.496 +native Float:GetConVarFloat(Handle:convar);
1.497 +
1.498 +/**
1.499 + * Sets the floating point value of a console variable.
1.500 + *
1.501 + * @param convar Handle to the convar.
1.502 + * @param value New floating point value.
1.503 + * @param replicate If set to true, the new convar value will be set on all clients.
1.504 + * This will only work if the convar has the FCVAR_REPLICATED flag
1.505 + * and actually exists on clients.
1.506 + * @param notify If set to true, clients will be notified that the convar has changed.
1.507 + * This will only work if the convar has the FCVAR_NOTIFY flag.
1.508 + * @noreturn
1.509 + * @error Invalid or corrupt Handle.
1.510 + */
1.511 +native SetConVarFloat(Handle:convar, Float:value, bool:replicate=false, bool:notify=false);
1.512 +
1.513 +/**
1.514 + * Retrieves the string value of a console variable.
1.515 + *
1.516 + * @param convar Handle to the convar.
1.517 + * @param value Buffer to store the value of the convar.
1.518 + * @param maxlength Maximum length of string buffer.
1.519 + * @noreturn
1.520 + * @error Invalid or corrupt Handle.
1.521 + */
1.522 +native GetConVarString(Handle:convar, String:value[], maxlength);
1.523 +
1.524 +/**
1.525 + * Sets the string value of a console variable.
1.526 + *
1.527 + * @param convar Handle to the convar.
1.528 + * @param value New string value.
1.529 + * @param replicate If set to true, the new convar value will be set on all clients.
1.530 + * This will only work if the convar has the FCVAR_REPLICATED flag
1.531 + * and actually exists on clients.
1.532 + * @param notify If set to true, clients will be notified that the convar has changed.
1.533 + * This will only work if the convar has the FCVAR_NOTIFY flag.
1.534 + * @noreturn
1.535 + * @error Invalid or corrupt Handle.
1.536 + */
1.537 +native SetConVarString(Handle:convar, const String:value[], bool:replicate=false, bool:notify=false);
1.538 +
1.539 +/**
1.540 + * Resets the console variable to its default value.
1.541 + *
1.542 + * @param convar Handle to the convar.
1.543 + * @param replicate If set to true, the new convar value will be set on all clients.
1.544 + * This will only work if the convar has the FCVAR_REPLICATED flag
1.545 + * and actually exists on clients.
1.546 + * @param notify If set to true, clients will be notified that the convar has changed.
1.547 + * This will only work if the convar has the FCVAR_NOTIFY flag.
1.548 + * @noreturn
1.549 + * @error Invalid or corrupt Handle.
1.550 + */
1.551 +native ResetConVar(Handle:convar, bool:replicate=false, bool:notify=false);
1.552 +
1.553 +/**
1.554 + * Returns the bitstring of flags on a console variable.
1.555 + *
1.556 + * @param convar Handle to the convar.
1.557 + * @return A bitstring containing the FCVAR_* flags that are enabled.
1.558 + * @error Invalid or corrupt Handle.
1.559 + */
1.560 +native GetConVarFlags(Handle:convar);
1.561 +
1.562 +/**
1.563 + * Sets the bitstring of flags on a console variable.
1.564 + *
1.565 + * @param convar Handle to the convar.
1.566 + * @param flags A bitstring containing the FCVAR_* flags to enable.
1.567 + * @noreturn
1.568 + * @error Invalid or corrupt Handle.
1.569 + */
1.570 +native SetConVarFlags(Handle:convar, flags);
1.571 +
1.572 +/**
1.573 + * Retrieves the specified bound of a console variable.
1.574 + *
1.575 + * @param convar Handle to the convar.
1.576 + * @param type Type of bound to retrieve, ConVarBound_Lower or ConVarBound_Upper.
1.577 + * @param value By-reference cell to store the specified floating point bound value.
1.578 + * @return True if the convar has the specified bound set, false otherwise.
1.579 + * @error Invalid or corrupt Handle.
1.580 + */
1.581 +native bool:GetConVarBounds(Handle:convar, ConVarBounds:type, &Float:value);
1.582 +
1.583 +/**
1.584 + * Sets the specified bound of a console variable.
1.585 + *
1.586 + * @param convar Handle to the convar.
1.587 + * @param type Type of bound to set, ConVarBound_Lower or ConVarBound_Upper
1.588 + * @param set If set to true, convar will use specified bound. If false, bound will be removed.
1.589 + * @param value Floating point value to use as the specified bound.
1.590 + * @noreturn
1.591 + * @error Invalid or corrupt Handle.
1.592 + */
1.593 +native SetConVarBounds(Handle:convar, ConVarBounds:type, bool:set, Float:value=0.0);
1.594 +
1.595 +/**
1.596 + * Retrieves the name of a console variable.
1.597 + *
1.598 + * @param convar Handle to the convar.
1.599 + * @param value Buffer to store the name of the convar.
1.600 + * @param maxlength Maximum length of string buffer.
1.601 + * @noreturn
1.602 + * @error Invalid or corrupt Handle.
1.603 + */
1.604 +native GetConVarName(Handle:convar, const String:name[], maxlength);
1.605 +
1.606 +funcenum ConVarQueryFinished
1.607 +{
1.608 + /**
1.609 + * Called when a query to retrieve a client's console variable has finished.
1.610 + *
1.611 + * @param cookie Unique identifier of query.
1.612 + * @param client Player index.
1.613 + * @param result Result of query that tells one whether or not query was successful.
1.614 + * See ConVarQueryResult enum for more details.
1.615 + * @param convarName Name of client convar that was queried.
1.616 + * @param convarValue Value of client convar that was queried if successful. This will be "" if it was not.
1.617 + * @param value Value that was passed when query was started.
1.618 + * @noreturn
1.619 + */
1.620 + public(QueryCookie:cookie, client, ConVarQueryResult:result, const String:cvarName[], const String:cvarValue[], any:value),
1.621 +
1.622 + /**
1.623 + * Called when a query to retrieve a client's console variable has finished.
1.624 + *
1.625 + * @param cookie Unique identifier of query.
1.626 + * @param client Player index.
1.627 + * @param result Result of query that tells one whether or not query was successful.
1.628 + * See ConVarQueryResult enum for more details.
1.629 + * @param convarName Name of client convar that was queried.
1.630 + * @param convarValue Value of client convar that was queried if successful. This will be "" if it was not.
1.631 + * @noreturn
1.632 + */
1.633 + public(QueryCookie:cookie, client, ConVarQueryResult:result, const String:cvarName[], const String:cvarValue[])
1.634 +};
1.635 +
1.636 +/**
1.637 + * Starts a query to retrieve the value of a client's console variable.
1.638 + *
1.639 + * @param client Player index.
1.640 + * @param name Name of client convar to query.
1.641 + * @param callback A function to use as a callback when the query has finished.
1.642 + * @param value Optional value to pass to the callback function.
1.643 + * @return A cookie that uniquely identifies the query.
1.644 + * Returns QUERYCOOKIE_FAILED on failure, such as when used on a bot.
1.645 + */
1.646 +native QueryCookie:QueryClientConVar(client, const String:cvarName[], ConVarQueryFinished:callback, any:value=0);
1.647 +
1.648 +/**
1.649 + * Gets a command iterator. Must be freed with CloseHandle().
1.650 + *
1.651 + * @return A new command iterator.
1.652 + */
1.653 +native Handle:GetCommandIterator();
1.654 +
1.655 +/**
1.656 + * Reads a command iterator, then advances to the next command if any.
1.657 + * Only SourceMod specific commands are returned.
1.658 + *
1.659 + * @param iter Command iterator Handle.
1.660 + * @param name Name buffer.
1.661 + * @param nameLen Name buffer size.
1.662 + * @param eflags Effective default flags of a command.
1.663 + * @param desc Command description buffer.
1.664 + * @param descLen Command description buffer size.
1.665 + * @return True on success, false if there are no more commands.
1.666 + */
1.667 +native bool:ReadCommandIterator(Handle:iter,
1.668 + String:name[],
1.669 + nameLen,
1.670 + &eflags=0,
1.671 + String:desc[]="",
1.672 + descLen=0);
1.673 +
1.674 +/**
1.675 + * Returns whether a client has access to a given command string. The string
1.676 + * can also be any override string, as overrides can be independent of
1.677 + * commands. This important feature essentially allows you to create custom
1.678 + * flags using the override system.
1.679 + *
1.680 + * @param client Client index.
1.681 + * @param command Command name. If the command is not found, the default
1.682 + * flags are used.
1.683 + * @param flags Flag string to use as a default, if the command or override
1.684 + * is not found.
1.685 + * @param override_only If true, SourceMod will not attempt to find a matching
1.686 + * command, and it will only use the default flags specified.
1.687 + * Otherwise, SourceMod will ignore the default flags if
1.688 + * there is a matching admin command.
1.689 + * @return True if the client has access, false otherwise.
1.690 + */
1.691 +native bool:CheckCommandAccess(client,
1.692 + const String:command[],
1.693 + flags,
1.694 + bool:override_only=false);
1.695 +
1.696 +/**
1.697 + * Returns true if the supplied character is valid in a ConVar name.
1.698 + *
1.699 + * @param c Character to validate.
1.700 + * @return True is valid for ConVars, false otherwise
1.701 + */
1.702 +stock bool:IsValidConVarChar(c)
1.703 +{
1.704 + return (c == '_' || IsCharAlpha(c) || IsCharNumeric(c));
1.705 +}
1.706 +
1.707 +/**
1.708 + * Returns the bitstring of flags of a command.
1.709 + *
1.710 + * @param name Name of the command.
1.711 + * @return A bitstring containing the FCVAR_* flags that are enabled
1.712 + * or INVALID_FCVAR_FLAGS if command not found.
1.713 + */
1.714 +native GetCommandFlags(const String:name[]);
1.715 +
1.716 +/**
1.717 + * Sets the bitstring of flags of a command.
1.718 + *
1.719 + * @param name Name of the command.
1.720 + * @param flags A bitstring containing the FCVAR_* flags to enable.
1.721 + * @return True on success, otherwise false.
1.722 + */
1.723 +native bool:SetCommandFlags(const String:name[], flags);
1.724 +
1.725 +/**
1.726 + * Starts a ConCommandBase search, traversing the list of ConVars and
1.727 + * ConCommands. If a Handle is returned, the next entry must be read
1.728 + * via FindNextConCommand(). The order of the list is undefined.
1.729 + *
1.730 + * @param buffer Buffer to store entry name.
1.731 + * @param max_size Maximum size of the buffer.
1.732 + * @param isCommand Variable to store whether the entry is a command.
1.733 + * If it is not a command, it is a ConVar.
1.734 + * @param flags Variable to store entry flags.
1.735 + * @param description Buffer to store the description, empty if no description present.
1.736 + * @param descrmax_size Maximum size of the description buffer.
1.737 + * @return On success, a ConCmdIter Handle is returned, which
1.738 + * can be read via FindNextConCommand(), and must be
1.739 + * closed via CloseHandle(). Additionally, the output
1.740 + * parameters will be filled with information of the
1.741 + * first ConCommandBase entry.
1.742 + * On failure, INVALID_HANDLE is returned, and the
1.743 + * contents of outputs is undefined.
1.744 + */
1.745 +native Handle:FindFirstConCommand(String:buffer[], max_size, &bool:isCommand, &flags=0, String:description[]="", descrmax_size=0);
1.746 +
1.747 +/**
1.748 + * Reads the next entry in a ConCommandBase iterator.
1.749 + *
1.750 + * @param search ConCmdIter Handle to search.
1.751 + * @param buffer Buffer to store entry name.
1.752 + * @param max_size Maximum size of the buffer.
1.753 + * @param isCommand Variable to store whether the entry is a command.
1.754 + * If it is not a command, it is a ConVar.
1.755 + * @param flags Variable to store entry flags.
1.756 + * @param description Buffer to store the description, empty if no description present.
1.757 + * @param descrmax_size Maximum size of the description buffer.
1.758 + * @return On success, the outputs are filled, the iterator is
1.759 + * advanced to the next entry, and true is returned.
1.760 + * If no more entries exist, false is returned, and the
1.761 + * contents of outputs is undefined.
1.762 + */
1.763 +native bool:FindNextConCommand(Handle:search, String:buffer[], max_size, &bool:isCommand, &flags=0, String:description[]="", descrmax_size=0);
1.764 +
1.765 +/**
1.766 + * Replicates a convar value to a specific client. This does not change the actual convar value.
1.767 + *
1.768 + * @param client Client index
1.769 + * @param convar ConVar handle
1.770 + * @param value String value to send
1.771 + * @return True on success, false on failure
1.772 + * @error Invalid client index, client not in game, or client is fake
1.773 + */
1.774 +native bool:SendConVarValue(client, Handle:convar, const String:value[]);