{"name":"serverCommand","operator":null,"title":"serverCommand","type":"command","url":"https://community.bistudio.com/wiki/serverCommand","revid":377886,"updated":"2026-01-04T16:30:46Z","groups":["Multiplayer"],"status":"ok","replaced_by":[],"games":[{"game":"arma2","name":"Arma 2","version":"1.05"},{"game":"arma2oa","name":"Arma 2: Operation Arrowhead","version":"1.50"},{"game":"tkoh","name":"Take On Helicopters","version":"1.00"},{"game":"arma3","name":"Arma 3","version":"0.50"}],"since":{"game":"arma2","name":"Arma 2","version":"1.05"},"arma3_since":"0.50","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"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","since":null,"effect":null,"exec":null,"params":[{"name":"command","type":"String","optional":false,"default":null,"description":null,"types":["String"],"since":null,"text":"command: String"}],"returns":{"type":"Boolean","types":["Boolean"],"description":"false if a non valid command is used (\"#blah\"), false otherwise (was always true before Arma 3 v1.40)","text":"Boolean - false if a non valid command is used (\"#blah\"), false otherwise (was always true before Arma 3 v1.40)"},"form":"unary","operator":null,"left":null,"right":{"text":"command","types":["String"]}},{"syntax":"password serverCommand command","since":"arma3 1.40","effect":null,"exec":"server","params":[{"name":"password","type":"String","optional":false,"default":null,"description":"case-sensitive password defined in server config with `serverCommandPassword` param","types":["String"],"since":null,"text":"password: String - case-sensitive password defined in server config with `serverCommandPassword` param"},{"name":"command","type":"String","optional":false,"default":null,"description":"server command","types":["String"],"since":null,"text":"command: String - server command"}],"returns":{"type":"Boolean","types":["Boolean"],"description":"false if command failed at some stage. true doesn't mean that command succeeded.","text":"Boolean - false if command failed at some stage. true doesn't mean that command succeeded."},"form":"binary","operator":null,"left":{"text":"password","types":["String"]},"right":{"text":"command","types":["String"]}}],"examples":[{"text":"```sqf\nserverCommand \"#logout\";\n```","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};"]},{"text":"```sqf\nserverCommand format [\"#kick %1\",_name];\n```","code":["serverCommand format [\"#kick %1\",_name];"]},{"text":"```sqf\nprivate _passwordWasOK = \"MyServerCommandPassword\" serverCommand \"#lock\";\n```","code":["private _passwordWasOK = \"MyServerCommandPassword\" serverCommand \"#lock\";"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["serverCommandAvailable","serverCommandExecutable","admin","isUIContext"],"notes":[],"categories":["Arma 2: New Scripting Commands","Arma 2: Operation Arrowhead: Scripting Commands","Arma 2: Scripting Commands","Arma 3: Scripting Commands","Command Group: Multiplayer","Introduced with Arma 2 version 1.05","Introduced with Arma 3 version 1.40","Scripting Commands","Scripting Commands: Server Execution","Take On Helicopters: Scripting Commands"]}