serverCommand: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "{{since" to "{{Since")
m (Text replacement - "_{10,} " to "")
Line 1: Line 1:
{{Command|Comments=
{{Command|Comments=
____________________________________________________________________________________________


| arma2 |Game name=
| arma2 |Game name=
Line 7: Line 6:


|gr1= Multiplayer |GROUP1=
|gr1= Multiplayer |GROUP1=
____________________________________________________________________________________________


| Executes the given [[Multiplayer_Server_Commands|server command]].
| Executes the given [[Multiplayer_Server_Commands|server command]].
Line 16: Line 14:


{{Feature|arma3 | As of {{arma3}} v1.39 an alternative version of [[serverCommand]] can be used on dedicated server and headless clients. It requires a password, set with <tt>serverCommandPassword</tt> in [[server.cfg]] and passed to the command as an argument (See Alt Syntax).}} |DESCRIPTION=  
{{Feature|arma3 | As of {{arma3}} v1.39 an alternative version of [[serverCommand]] can be used on dedicated server and headless clients. It requires a password, set with <tt>serverCommandPassword</tt> in [[server.cfg]] and passed to the command as an argument (See Alt Syntax).}} |DESCRIPTION=  
____________________________________________________________________________________________


| [[serverCommand]] command |SYNTAX=
| [[serverCommand]] command |SYNTAX=
Line 23: Line 20:


| [[Boolean]] - always [[true]] for some reason (since {{arma3}} v1.39 also [[false]] if a non valid command is used ("#blah")) |RETURNVALUE=
| [[Boolean]] - always [[true]] for some reason (since {{arma3}} v1.39 also [[false]] if a non valid command is used ("#blah")) |RETURNVALUE=
____________________________________________________________________________________________


|s2= password [[serverCommand]] command {{Since|arma3|1.39|y}} {{ServerExec}}|SYNTAX2=
|s2= password [[serverCommand]] command {{Since|arma3|1.39|y}} {{ServerExec}}|SYNTAX2=
Line 31: Line 27:


|r2= [[Boolean]] - [[true]] if password is correct |RETURNVALUE2=
|r2= [[Boolean]] - [[true]] if password is correct |RETURNVALUE2=
__________________________________________________________________


|x1= <code>[[serverCommand]] "#logout";</code>
|x1= <code>[[serverCommand]] "#logout";</code>

Revision as of 02:29, 17 January 2021

Hover & click on the images for description

Description

Description:
Executes the given server command.
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).
Arma 3
As of Arma 3 v1.39 an alternative version of serverCommand can be used on dedicated server and headless clients. It requires a password, set with serverCommandPassword in server.cfg and passed to the command as an argument (See Alt Syntax).
Groups:
Multiplayer

Syntax

Syntax:
serverCommand command
Parameters:
command : String
Return Value:
Boolean - always true for some reason (since Arma 3 v1.39 also false if a non valid command is used ("#blah"))

Alternative Syntax

Syntax:
password serverCommand command Template:Since Template:ServerExec
Parameters:
password : String - password defined in server.cfg with serverCommandPassword param
command : String - server command
Return Value:
Boolean - true if password is correct

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 { 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:
_passwordWasOK = "MyServerCommandPassword" serverCommand "#lock";

Additional Information

See also:
serverCommandAvailableserverCommandExecutableadminisUIContext

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note

Notes

Bottom Section