-
Notifications
You must be signed in to change notification settings - Fork 4
ConCommandSystem
The Angelscript API provides a means to create custom console commands and variables, as well as client commands.
There are 3 kinds of commands:
- Server command
- Server variable
- Client command
Server commands can only be used by the host and/or through rcon. Client commands can be executed by any connected client.
Commands can have a number of flags set on them:
Flag | Description |
---|---|
ConCommandFlag::None | Constant used to indicate the absence of flags. |
ConCommandFlag::AdminOnly | If set, the invoking player (if any) must have admin access. |
ConCommandFlag::Cheat | If set, the invoking player (if any) must have cheat access. |
The following classes are part of the command system API:
Class | Description |
---|---|
CCommand | Contains the arguments that were given for this command, including the command name itself. |
CConCommand | Represents a server command. |
CCVar | Represents a server variable. |
CClientCommand | Represents a client command. |
CConCommandSystem | Represents the console command system as a whole. |
Creating a custom command is relatively simple. All you have to do is create a global instance of the command kind you want to create and specify its name and other parameters.
For example, to create a new server command named "mycommand":
void MyCommandFunc( const CCommand@ pArgs )
{
g_Game.AlertMessage( at_console, "Hello world!\n" );
}
CConCommand mycommand( "mycommand", "this is my command", @MyCommandFunc );
All custom commands created in plugins have a dot '.' prepended to their name to prevent name conflicts, and to prevent built-in commands added in the future from conflicting. Map scripts do not have this limitation.
Plugins also have a concept of namespaces: a server operator can specify a console command namespace to put all commands into their own namespace, which helps prevent conflicts between plugins. The namespace is prepended to the name, in front of the dot.
See the Plugin list file documentation for more information.
To use a custom server command, you will have to use the as_command
console command to forward it to Angelscript. This is an engine limitation.
For example:
as_command .mycommand
If you are using rcon, you will have to specify as_command
as well:
rcon as_command .mycommand
Client commands do not have this limitation, and can be executed by using their name on their own, but still including the namespace and dot.
In addition to as_command
, there are a few other console commands that pertain to Angelscript's console command system:
This command displays console command statistics to the server console. This currently only covers the number of commands.
Removes all commands from the system. This is used to purge commands if a plugin or map script breaks anything. Only admins can use this.
This command will find any commands that are registered by any scripts.
Syntax: as_findcommands <substring>
: Finds all commands that match the given substring.