dreamworkAPI
Ctrl K
GitHub
classDocs / console / Command

console.Command

classsharedmenusource
Object → console.Command

The console command object.

Constructor

console.Command(options: console.CommandOptions): console.Command

Fields

NameTypeDescription
namestringThe name of the command.
descriptionstringThe description of the command.
flagsintegerThe flags of the command.
autocompleteconsole.Command.AutoComplete | nilThe auto-complete function of the command.
unregisteredboolean?If this is set, don't add to linked list, etc. READ-ONLY
development_onlyboolean?Hidden in released products. Flag is removed automatically if ALLOW_DEVELOPMENT_CVARS is defined in C++. READ-ONLY
game_dllboolean?Defined by the game DLL. READ-ONLY
client_dllboolean?Defined by the client DLL. READ-ONLY
hiddenboolean?Doesn't appear in find or autocomplete. Like development_only, but can't be compiled out. READ-ONLY
protectedboolean?It's a server cvar, but we don't send the data since it's a password, etc. Sends 1 if it's not blank/zero, 0 otherwise as value. Garry's Mod never calls cvars.OnConVarChanged for protected variables, so console.Variable keeps the first value it read and never emits "change". READ-ONLY
sponlyboolean?This cvar cannot be changed by clients connected to a multiplayer server. READ-ONLY
archiveboolean?Save the cvar value into either client.vdf or server.vdf. READ-ONLY
notifyboolean?For server-side cvars, notifies all players with blue chat text when the value gets changed, also makes the convar appear in A2S_RULES. READ-ONLY
userinfoboolean?For client-side commands, sends the value to the server. READ-ONLY
cheatboolean?In multiplayer, prevents this command/variable from being used unless the server has sv_cheats turned on. If a client connects to a server where cheats are disabled (which is the default), all client side console variables labeled as cheat are reverted to their default values and can't be changed as long as the client stays connected. Console commands marked as cheat can't be executed either. As a general rule of thumb, any client-side command that isn't specifically meant to be configured by users should be marked with this flag, as even the most harmless looking commands can sometimes be misused to cheat. For server-side only commands you can be more lenient, since these would have no effect when changed by connected clients anyway. READ-ONLY
printable_onlyboolean?This cvar's string cannot contain unprintable characters ( e.g., used for player name etc ). READ-ONLY
unloggedboolean?If this is a server-side, don't log changes to the log file / console if we are creating a log. READ-ONLY
never_as_stringboolean?Tells the engine to never print this console variable as a string. This is used for variables which may contain control characters. READ-ONLY
replicatedboolean?When set on a console variable, all connected clients will be forced to match the server-side value. This should be used for shared code where it's important that both sides run the exact same path using the same data. (e.g. predicted movement/weapons, game rules) READ-ONLY
demoboolean?When starting to record a demo file, explicitly adds the value of this console variable to the recording to ensure a correct playback. READ-ONLY
dont_recordboolean?Opposite of demo, ensures the cvar is not recorded in demos. READ-ONLY
reload_materialsboolean?If set and this variable changes, it forces a material reload. READ-ONLY
reload_texturesboolean?If set and this variable changes, it forces a texture reload. READ-ONLY
not_connectedboolean?Prevents this variable from being changed while the client is currently in a server, due to the possibility of exploitation of the command (e.g. fps_max). READ-ONLY
material_system_threadboolean?Indicates this cvar is read from the material system thread. READ-ONLY
archive_xboxboolean?Like archive, but for Xbox 360. Needless to say, this is not particularly useful to most modders. Save the cvar value into config.vdf on XBox. READ-ONLY
accessible_from_threadsboolean?Used as a debugging tool necessary to check material system thread convars. READ-ONLY
server_can_executeboolean?The server is allowed to execute this command on clients via ClientCommand/NET_StringCmd/CBaseClientState::ProcessStringCmd. READ-ONLY
server_cannot_queryboolean?If this is set, then the server is not allowed to query this cvar's value (via IServerPluginHelpers::StartQueryCvarValue). READ-ONLY
clientcmd_can_executeboolean?IVEngineClient::ClientCmd is allowed to execute this command. READ-ONLY
material_thread_maskboolean?Summary of reload_materials, reload_textures and material_system_thread. READ-ONLY
lua_clientboolean?Sets automatically on all cvars and console commands created by the client Lua state. READ-ONLY
lua_serverboolean?Sets automatically on all cvars and console commands created by the server Lua state. READ-ONLY

Static functions

getReturns the console command with the given name.
isBlacklistedChecks if the console command is blacklisted.
translateAliasTranslates a console command alias, basically reverse of the alias console command.

#console.Command.get

sharedmenunodiscardsource
function console.Command.get(name: any): console.Command | nil

Returns the console command with the given name.

Parameters
NameTypeDescription
nameany
Returns
TypeNameDescription
console.Command | nilobjThe console command with the given name, or nil if it does not exist.

#console.Command.isBlacklisted

sharedmenunodiscardsource
function console.Command.isBlacklisted(name: string): boolean

Checks if the console command is blacklisted.

Parameters
NameTypeDescription
namestringThe name of the console command.
Returns
TypeNameDescription
booleanis_blacklistedtrue if the console command is blacklisted, false otherwise.

#console.Command.translateAlias

clientmenunodiscardsource
function console.Command.translateAlias(str: string): string | nil

Translates a console command alias, basically reverse of the alias console command.

Parameters
NameTypeDescription
strstringThe alias to lookup.
Returns
TypeNameDescription
string | nilcmdThe command(s) this alias will execute if ran, or nil if the alias doesn't exist.

Methods

attachAttaches a handler called on every execution of the command, attaching the same handler twice is a no-op.
awaitWaits for the console command to be executed.
clearRemoves every handler of the command, pending handlers of a running execution are skipped.
detachDetaches a handler previously passed to attach or once.
isBlacklistedReturns whether the console command is blacklisted.
onceAttaches a one-shot handler, detached right before the next execution calls it.
runRuns the console command.

#Command:attach

sharedmenusource
function console.Command:attach(handler: console.Command.Callback | Hook | Event)

Attaches a handler called on every execution of the command, attaching the same handler twice is a no-op.

Handlers run in protected mode, one failing handler is reported and never stops the others.

Parameters
NameTypeDescription
handlerconsole.Command.Callback | Hook | EventThe callback or callable object.

#Command:await

sharedmenuasyncsource
async function console.Command:await(): console.Command, garrysmod.Player | nil, string[], string

Waits for the console command to be executed.

Returns
TypeNameDescription
console.Commandcommand
garrysmod.Player | nilclient
string[]args
stringargument_string

#Command:clear

sharedmenusource
function console.Command:clear()

Removes every handler of the command, pending handlers of a running execution are skipped.

#Command:detach

sharedmenusource
function console.Command:detach(handler: console.Command.Callback | Hook | Event): boolean

Detaches a handler previously passed to attach or once.

Parameters
NameTypeDescription
handlerconsole.Command.Callback | Hook | EventThe exact handler reference.
Returns
TypeNameDescription
booleanremovedtrue if the handler was attached.

#Command:isBlacklisted

sharedmenunodiscardsource
function console.Command:isBlacklisted(): boolean

Returns whether the console command is blacklisted.

Returns
TypeNameDescription
booleanis_blacklistedtrue if the console command is blacklisted, false otherwise.

#Command:once

sharedmenusource
function console.Command:once(handler: console.Command.Callback | Hook | Event)

Attaches a one-shot handler, detached right before the next execution calls it.

Parameters
NameTypeDescription
handlerconsole.Command.Callback | Hook | EventThe callback or callable object.

#Command:run

sharedmenusource
function console.Command:run(...: string)

Runs the console command.

Parameters
NameTypeDescription
...stringThe arguments to pass to the console command.

Subclasses

console.Variable

Generated from the dreamwork meta branch.