Skip to content

Adding New Chat Commands

Adding new chat commands is a great way to add custom functionality to servers which feature your mod. Custom chat commands can be anything from displaying some information to a user, to spawning a horde of objects.

Add A New Chat Command

Add a new blueprint that is derived from IChatCommand.

  1. Navigate to the Blueprints/ChatCommands folder. If it does not exist, create it.
  2. Press the Add button in the content browser.
  3. Select Blueprint Class
  4. Search for the IChatCommand class under "All Classes".
  5. Select IChatCommand.
  6. Name the blueprint. Something like BP_ExampleCommand will be fine, but it is up to you.

add_new_chat_command_bpsearch_chatcommand

Editing The Default Values

Now you can open that blueprint by double clicking on it, and edit the default values.

  • Command Name is the name that's used by the user when executing the command.
  • Description is the text that is displayed to the user when the "Help" command is executed.
  • Permission is the value that is used by player roles to determine which player roles have access to this command. If left empty, the permission is the command name. It can be useful to set this permission if making a group of commands which all use the same permission (teleport, bring, goto all use "teleport" permission).
  • Command Type determines how the command is executed.
    • ServerCommand means that the command will be executed on the server. This is important for commands that effect other players or require other player data, or any data that a client does not have access to.
    • ClientCommand is a command that is run on a client. Use this one if you don't need any server-only data.
    • StandaloneCommand is the same as 'ServerCommand', except that a Player Controller is not passed through, meaning this command can be executed remotely (via RCON).
  • Requires Permission If on, the command requires the permission specified by the Permission field.
  • Hidden If on, this command is not displayed with the "Help" command or in the roles editor.

An example:

example_command_values

Make It Discoverable

To make it usable in the game, it needs to be discoverable by the asset registry, and to do that we need to have a reference to our chat command in a ChatCommandDataAsset. These are found automatically when running the game.

  1. Navigate to the Blueprints/ChatCommands folder.
  2. Press the Add button in the content browser.
  3. Go into the Miscellaneous category.
  4. Select Data Asset
  5. Search for ChatCommandDataAsset and select it.
  6. Name the data asset something like CC_ExampleCommand. (CC means Chat Command)
  7. Double click the data asset to open its editor.
  8. Set the IChatCommandRef member to your command. If you named it the same as in this guide, it will be named BP_ExampleCommandcommands_select_data_assetcommands_pick_classcommands_example_bp

Adding Functionality

Now it is time to give some functionality to your custom command. You can explore with the commands yourself, or there is some examples for creating some commands to get you started: Display the player's nameTeleport players to youUsing Parameters

Play The Game

If all goes well, now you can run the game, load a level, execute your command and see the results!

Footer Image

4a581e9