[FEATURE] Allow arbitrary RCon commands in chat commands #678
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There are communities that would like to use chat commands with a more powerful set of actions that can be triggered when a player uses a chat command. Two real-worl example from the "event server for prepping" use case:
Switching player side
Changing a side without needing to redeploy for themself, a command "!switch" is useful. Issuing this command will forward a switch_player_now RCon command with the player_name of the issuing player.
Redeploying with 10 instead of 20 seconds
Redeploying with the
punish
command might be useful when needing to redeploy for multiple times. A command "!redeploy", which issues apunish
command for the issuing player, might be useful here.This feature is implemented with this PR. A chat command can either have a
message
key or acommand
key (message takes precendence). Thecommand
config is an object that has the same signature and functinality as auto-settings commands.This allows for a powerful set of tools, while it also has some risks, as everything can now be executed with a player issuing a specific chat command.
The parameters of the command will replace message parameters same as the message itself, however, only context keys are populated. No other variables are available in commands params.
Example config
Conditions
As seen in the above example, conditions are available for these commands. This allows an admin to define commands which are only executed when the execution context matches certain conditions. These conditions are the same as in AutoSettings.
The PR adds two new conditions, which are only available when the metric source
player_id
is available. This metric source is currently only available in chat commands, not in auto settings. In auto settings, if one of these conditions is configured, it will always default to "condition is met".Automatic enablement and disablement
To make commands only available under certain conditions, a new api is available for auto settings, an example::
This api can be used with all the available conditions in the rules section as known for the other stuff..