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
- Available commands for execution can be found with serverCommandAvailable
- Commands that can be executed can be found with serverCommandExecutable
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:
command: String
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:
password: String - case-sensitive password defined in server config withserverCommandPasswordparamcommand: String - server command
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