Arma 3 Scripting

serverCommand

  • Arma 3 v0.50
  • First in Arma 2 v1.05

Command · Markdown · JSON · original wiki page

Description

Executes the given server command. Requires you to be logged-in admin as client to execute on a client, or provide the serverCommandPassword with the serverCommand execution as client/server to basically also get logged in admin permissions.

Note

Important

If serverCommand is executed on a client, it must be executed from UI context, such as "onButtonDown" or similar events (see User Interface Event Handlers).

Syntax

Syntax 1

serverCommand command

Parameters:

Returns: Boolean - false if a non valid command is used ("#blah"), false otherwise (was always true before Arma 3 v1.40)

Syntax 2

since arma3 1.40 · execution: server

password serverCommand command

Parameters:

Returns: Boolean - false if command failed at some stage. true doesn't mean that command succeeded.

Examples

Example 1

serverCommand "#logout";

Example 2

Create button on the main map which will show userlist to anyone who clicks on it:

with uiNamespace do
{
    private _ctrl = findDisplay 12 ctrlCreate ["RscButton", -1];
    _ctrl ctrlSetPosition [0,0,0.5,0.1];
    _ctrl ctrlSetText "USERLIST";
    _ctrl ctrlCommit 0;
    _ctrl ctrlAddEventHandler ["ButtonDown",
    {
        serverCommand "#userlist";
    }];
};

Example 3

serverCommand format ["#kick %1",_name];

Example 4

private _passwordWasOK = "MyServerCommandPassword" serverCommand "#lock";

See also

serverCommandAvailable · serverCommandExecutable · admin · isUIContext