Silent Creating Custom Commands

From MyGamingTalk

What Are Custom Commands

Custom commands are shrubbot like commands that are not implemented by the silEnT mod, but instead by server admins. There are three ways to create custom commands. One is to simply use the [command] blocks in the shrubbot.cfg. Second one is to combine [command] block with a Lua script that will do more complicated work than what just what the rcon can do. And the third method is to implement everything with Lua. The following sections describe each of these methods.

Shrubbot.cfg Method

The shrubbot.cfg file on your server can include following blocks:

   [command]
   command  = The name of the command.
   exec     = The executed command. These must be commands available to /rcon and these will be executed with rcon privileges.
   desc     = The help description of the command.
   syntax   = List of parameters if the command uses them. This is used with !help and it is optional.
   levels   = Space separated list of levels that are allowed to use the command.

These commands appear in the !help output just as if they were implemented by the silEnT mod itself. Also, !help <command name> can be used to see detailed help about the commands. The exec line defines the commands that will be executed by the mod. The exec field supports the following:

  • The commands can be anything that can be executed with /rcon.
  • The commands can use all shortcut that players can use with their chat messages.
  • In addition to the normal shortcuts, the shrubbot custom commands support parameter place holders. These are [1] - [9], where the number is the n:th parameter given to the custom command. When these are used, the server will substitute the placeholder with the n:th parameter given to the command.
  • There is also the possibility to add ? to the parameter placeholders. If the question mark is added, the parameter is substituted with a player name if only one name matches the pattern. If there are no matches or there are several matches, the command will fail and reports an informative error. All placeholders can have the question mark if that is needed for the command.

Example:

   [command]
   command  = crybaby
   exec     = playsound path/to/sound.wav; chat ^7"[1?]"^7 is crying like a little baby!
   desc     = Make someone cry like a baby
   syntax   = [name]
   levels   = 0 1 2 3 4 5

Notice that the [1?] is surrounded with " characters. This is done so that if the name has spaces, the command will still use the full name as one parameter. It wouldn't be strictly needed for this example, but some other commands could break from that.

Combining shrubbot.cfg and Lua Scripts

One method to extend what the commands can do, is to use a Lua script to implement the actual command operation. To do this, create a custom command to the shrubbot.cfg, which executes a command, which is not recognized by the silEnT mod. Such command will pass through to the et_ConsoleCommand Lua callback. Where it can be intercepted and proper actions can be taken. The advantage of this method is that the command privileges and help are handled by the silEnT mod. This includes the Admin Level Protection. In other words, it is easy to ensure that the command is not used by unwanted persons.

Only With Lua

Some servers use quite large and complicated additional command implementations that are implemented entirely by Lua scripting.