{"name":"serverCommand","title":"serverCommand","type":"command","url":"https://community.bistudio.com/wiki/serverCommand","revid":377886,"updated":"2026-01-04T16:30:46Z","groups":["Multiplayer"],"status":"ok","games":{"arma2":"1.05","arma2oa":"1.50","tkoh":"1.00","arma3":"0.50"},"since":"arma2 1.05","arma3_since":"0.50","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.\n\n> [!NOTE]\n> - Available commands for execution can be found with serverCommandAvailable\n> - Commands that can be executed can be found with serverCommandExecutable\n\n> [!IMPORTANT]\n> 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).","syntaxes":[{"syntax":"serverCommand command","params":[{"name":"command","type":"String","type_expr":"String"}],"returns":{"type":"Boolean","type_expr":"Boolean","description":"false if a non valid command is used (\"#blah\"), false otherwise (was always true before Arma 3 v1.40)"},"form":"unary","right":{"text":"command"}},{"syntax":"password serverCommand command","since":"arma3 1.40","server_exec":true,"params":[{"name":"password","type":"String","description":"case-sensitive password defined in server config with `serverCommandPassword` param","type_expr":"String"},{"name":"command","type":"String","description":"server command","type_expr":"String"}],"returns":{"type":"Boolean","type_expr":"Boolean","description":"false if command failed at some stage. true doesn't mean that command succeeded."},"form":"binary","left":{"text":"password"},"right":{"text":"command"}}],"examples":[{"code":["serverCommand \"#logout\";"]},{"text":"Create button on the main map which will show userlist to anyone who clicks on it:\n\n```sqf\nwith uiNamespace do\n{\n    private _ctrl = findDisplay 12 ctrlCreate [\"RscButton\", -1];\n    _ctrl ctrlSetPosition [0,0,0.5,0.1];\n    _ctrl ctrlSetText \"USERLIST\";\n    _ctrl ctrlCommit 0;\n    _ctrl ctrlAddEventHandler [\"ButtonDown\",\n    {\n        serverCommand \"#userlist\";\n    }];\n};\n```","code":["with uiNamespace do \n{\n\tprivate _ctrl = findDisplay 12 ctrlCreate [\"RscButton\", -1];\n\t_ctrl ctrlSetPosition [0,0,0.5,0.1];\n\t_ctrl ctrlSetText \"USERLIST\";\n\t_ctrl ctrlCommit 0;\n\t_ctrl ctrlAddEventHandler [\"ButtonDown\", \n\t{\n\t\tserverCommand \"#userlist\";\n\t}];\n};"]},{"code":["serverCommand format [\"#kick %1\",_name];"]},{"code":["private _passwordWasOK = \"MyServerCommandPassword\" serverCommand \"#lock\";"]}],"see_also":["serverCommandAvailable","serverCommandExecutable","admin","isUIContext"],"categories_extra":["Introduced with Arma 3 version 1.40","Scripting Commands: Server Execution"]}