CfgDisabledCommands – Arma 3

From Bohemia Interactive Community
Revision as of 20:54, 30 October 2017 by Stokesgamingmc (talk | contribs) (Document commands that don't have left and right syntax.)
Jump to navigation Jump to search

Arma 3 logo black.png1.66

The CfgDisabledCommands is a mission config class which allows to disable selected scripting commands in a mission. It is a powerful tool and can make or break your game, since some of the default in-game mechanics also uses scripting. The use of CfgDisabledCommands feature requires advanced knowledge of scripting and should not be attempted unless the mission maker is confident in his abilities and is aware of potential dangers


Motivation

This powerful feature was developed in an attempt to give mission maker a tool, which allows him to increase security of multiplayer missions against possible hacking and exploits. Many mission makers choose to move important code to server side, however some script command left on client side may prove it difficult to achieve desired security goal. Disabling them altogether while mission is running could be the answer to some of the common issues. This feature has been enabled in the game since Arma 3 v1.66.

Mechanics

Commands listed in CfgDisabledCommands are disabled on mission start. This means that they are fully available in pre-init phase, therefore allowing mission maker to initialise the mission properly. Commands could be disabled on server, clients and HCs separately, giving even more flexibility to mission maker. If command is disabled on client, for example, remote executing it on client from server will have no effect. Any attempt of using disabled command after mission start will result in error message in .rpt file, while command itself will be ignored as if it didn't exist. The disabling is final and cannot be overridden during mission. Some commands have alternative syntaxes, therefore in order to disable command, the desired syntax has to be indicated (about this later).

Structure

Here is an example config, which disables createUnit, the one with remote exec ability, and createVehicleLocal on clients:

class CfgDisabledCommands
{
    class CREATEUNIT
    {
        class SYNTAX1
        {
            targets[] = {1,0,1};
            args[] = {{"STRING"},{"ARRAY"}};
        };
    };
    class CREATEVEHICLELOCAL
    {
        class SYNTAX1
        {
            targets[] = {1,0,1};
            args[] = {{"STRING"},{"ARRAY"}};
        };
    };
};

As you can see, the structure consists of definition of commands (CREATEUNIT, CREATEVEHICLELOCAL), definition of syntax (args[]) and target locality (targets[]):

  • targets[] - the format is {enableServer,enableClient,enableHC}. 1 means enable, 0 means disable. From the above example targets[] = {1,0,1}; means: enable server, disable client, enable HC.
  • args[] - the format is {{leftArgumentType},{rightArgumentType}}. The information about argument types could be retrieved with supportInfo command, but you do not have to do this as you can use CfgDisabledCommand Utility to generate CfgDisabledCommands template. Simply open debug console and type utils 1 then click on LOCAL EXEC (available since Arma 3 v1.67)

CfgDisabledCommands.jpg

Selecting Correct Syntax

While createVehicleLocal has only 1 syntax, createUnit has 2 syntaxes:

...
class CREATEUNIT
{
    class SYNTAX1
    {
        targets[] = {1,1,1};
        args[] = {{"STRING"},{"ARRAY"}};
    };

    class SYNTAX2
    {
        targets[] = {1,1,1};
        args[] = {{"GROUP"},{"ARRAY"}};
    };
};
...

From command page createUnit it is obvious that args[] = {{"STRING"},{"ARRAY"}}; is the syntax we want to keep as it is the syntax we want to disable since it allows for passed code to be remote executed everywhere, and thus presenting a security issue, so we leave it and delete the other syntax which is harmless in comparison. For other commands also refer to the respectful command pages. For example, setViewDistance:

class CfgDisabledCommands
{
    class SETVIEWDISTANCE
    {
        class SYNTAX1
        {
            targets[] = {1,1,1};
            args[] = {{},{"SCALAR"}};
        };
    };
};

Note that the command doesn't have left argument, so it is simply replaced with {}. After the correct syntax is selected and other syntaxes are removed, the targets could be configured according to mission design (by default enabled everywhere)

If a command doesn't have left arguments, or right arguments the correct syntax is:

class CfgDisabledCommands
{
    class ALLPLAYERS
    {
        targets[] = {1,1,1};
    };
};

Reminder

Once again, consider carefully what commands you want to disable and verify that disabling is not interfering with default functionality of the game. Don't forget to check .rpt file to avoid any confusion in the future.