serverCommand: Difference between revisions
Jump to navigation
Jump to search
m (Text replacement - "<h3 style="display:none">Bottom Section</h3> " to "") |
Lou Montana (talk | contribs) m (Text replacement - " *\| *([Cc]omments|COMMENTS|Game|[Gg]ame [Nn]ame( +[0-9])?|Game [Vv]ersion( +[0-9])?|Game Version \(number surrounded by NO SPACES\)|Arguments in MP|MP[Aa]rg|Multiplayer Arguments( \("local" or "global"\))?|Effects|Execution|Effects...) |
||
Line 1: | Line 1: | ||
{{Command | {{Command | ||
| arma2 | | arma2 | ||
|1.05 | |1.05 | ||
|gr1= Multiplayer | |gr1= Multiplayer | ||
| Executes the given [[Multiplayer_Server_Commands|server command]]. | | Executes the given [[Multiplayer_Server_Commands|server command]]. | ||
Line 13: | Line 13: | ||
{{Informative | If [[serverCommand]] is executed on a client, it must be executed from [[isUIContext | UI context]], such as ''onButtonDown'' or similar events (see [[User_Interface_Event_Handlers]]).}} | {{Informative | If [[serverCommand]] is executed on a client, it must be executed from [[isUIContext | UI context]], such as ''onButtonDown'' or similar events (see [[User_Interface_Event_Handlers]]).}} | ||
{{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).}} | {{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).}} | ||
| [[serverCommand]] command | | [[serverCommand]] command | ||
|p1= command : [[String]] | |p1= command : [[String]] | ||
| [[Boolean]] - always [[true]] for some reason (since {{arma3}} v1.39 also [[false]] if a non valid command is used ("#blah")) | | [[Boolean]] - always [[true]] for some reason (since {{arma3}} v1.39 also [[false]] if a non valid command is used ("#blah")) | ||
|s2= password [[serverCommand]] command {{Since|arma3|1.39|y}} {{ServerExec}} | |s2= password [[serverCommand]] command {{Since|arma3|1.39|y}} {{ServerExec}} | ||
|p21= password : [[String]] - password defined in [[server.cfg]] with <tt>serverCommandPassword</tt> param |PARAMETER21= | |p21= password : [[String]] - password defined in [[server.cfg]] with <tt>serverCommandPassword</tt> param |PARAMETER21= | ||
|p22= command : [[String]] - server command |PARAMETER22= | |p22= command : [[String]] - server command |PARAMETER22= | ||
|r2= [[Boolean]] - [[true]] if password is correct | |r2= [[Boolean]] - [[true]] if password is correct | ||
|x1= <code>[[serverCommand]] "#logout";</code> | |x1= <code>[[serverCommand]] "#logout";</code> | ||
Line 44: | Line 44: | ||
|x4 = <code>_passwordWasOK = "MyServerCommandPassword" [[serverCommand]] "#lock";</code> | |x4 = <code>_passwordWasOK = "MyServerCommandPassword" [[serverCommand]] "#lock";</code> | ||
| [[serverCommandAvailable]], [[serverCommandExecutable]], [[admin]], [[isUIContext]] | | [[serverCommandAvailable]], [[serverCommandExecutable]], [[admin]], [[isUIContext]] | ||
}} | }} | ||
Revision as of 12:03, 18 January 2021
Description
- Description:
- Executes the given server command.
- Available commands for execution can be found with serverCommandAvailable.
- Commands that can be executed can be found with serverCommandExecutable.
- 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
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