serverCommand: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(see also)
mNo edit summary
 
(59 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{Command|= Comments
{{RV|type=command
____________________________________________________________________________________________


| arma2 |= Game name
|game1= arma2
|version1= 1.05


|1.05|= Game version
|game2= arma2oa
|version2= 1.50


____________________________________________________________________________________________
|game3= tkoh
|version3= 1.00


| Executes the given [[Multiplayer_Server_Commands|a server command]]. Which command is available for execution can be found with [[serverCommandAvailable]] and whether or not it can be executed with [[serverCommandExecutable]]. 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]]).
|game4= arma3
<br><br>
|version4= 0.50


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 <tt>serverCommandPassword</tt> in [[server.cfg]] and passed to the command as an argument (See Alt Syntax)|= Description
|gr1= Multiplayer
____________________________________________________________________________________________


| '''serverCommand''' command |= Syntax
|descr= Executes the given [[Multiplayer_Server_Commands|server command]].
{{Feature|informative|
* Available commands for execution can be found with [[serverCommandAvailable]]
* Commands that can be executed can be found with [[serverCommandExecutable]]
}}
 
{{Feature|important|If [[serverCommand]] is executed on a client, it must be executed from [[isUIContext|UI context]], such as [[User Interface Event Handlers#onButtonDown|"onButtonDown"]] or similar events (see [[User Interface Event Handlers]]).}}
 
|s1= [[serverCommand]] command


|p1= command : [[String]] |= Parameter 1
|p1= command : [[String]]


| [[Boolean]] - always [[true]] for some reason (since A3 v1.39 also [[false]] if a non valid command is used ("#blah")) |= Return value
|r1= [[Boolean]] - [[false]] if a non valid command is used ("#blah"), false otherwise (was always [[true]] before {{GVI|arma3|1.40|size= 0.75}})
____________________________________________________________________________________________


| s2= password '''serverCommand''' command &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;''(since Arma 3 v1.39)'' {{ServerExec}}|= Syntax
|s2= password [[serverCommand]] command
|s2exec= server


|p21= password : [[String]] - password defined in [[server.cfg]] with <tt>serverCommandPassword</tt> param |= Parameter 1
|s2since= arma3 1.40
|p22= command : [[String]] - server command |= Parameter 2


| r2= [[Boolean]] - [[true]] if password is correct |= Return value
|p21= password : [[String]] - case-sensitive password defined in [[server.cfg]] with {{hl|serverCommandPassword}} param
__________________________________________________________________


|x1 = <code>[[serverCommand]] "#logout";</code>
|p22= command : [[String]] - server command
|x2 = Create button on the main map which will show userlist to anyone who clicks on it:
 
<code>[[with]] [[uiNamespace]] [[do]]
|r2= [[Boolean]] - [[false]] if command failed at some stage. [[true]] doesn't mean that command succeeded.
 
|x1= <sqf>serverCommand "#logout";</sqf>
 
|x2= Create button on the main map which will show userlist to anyone who clicks on it:
<sqf>with uiNamespace do  
{
{
ctrl = [[findDisplay]] 12 [[ctrlCreate]] ["RscButton", -1];
private _ctrl = findDisplay 12 ctrlCreate ["RscButton", -1];
ctrl [[ctrlSetPosition]] [0,0,0.5,0.1];
_ctrl ctrlSetPosition [0,0,0.5,0.1];
ctrl [[ctrlSetText]] "USERLIST";
_ctrl ctrlSetText "USERLIST";
ctrl [[ctrlCommit]] 0;
_ctrl ctrlCommit 0;
ctrl [[ctrlAddEventHandler]] ["ButtonDown",  
_ctrl ctrlAddEventHandler ["ButtonDown",  
{
{
[[serverCommand]] "#userlist";
serverCommand "#userlist";
}];
}];
};</code>
};</sqf>
|x3 = <code>[[serverCommand]] [[format]] ["#kick %1",_name];</code>
 
|x4 = <code>_passwordWasOK = "MyServerCommandPassword" [[serverCommand]] "#lock";</code>
|x3= <sqf>serverCommand format ["#kick %1",_name];</sqf>


| [[serverCommandAvailable]], [[serverCommandExecutable]], [[admin]], [[isUIContext]] |= See also
|x4= <sqf>private _passwordWasOK = "MyServerCommandPassword" serverCommand "#lock";</sqf>


|seealso= [[serverCommandAvailable]] [[serverCommandExecutable]] [[admin]] [[isUIContext]]
}}
}}


<h3 style="display:none">Notes</h3>
<dl class="command_description">
</dl>


<h3 style="display:none">Bottom Section</h3>
[[Category:Scripting Commands: Server Execution]]
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]
[[Category:Introduced with Arma 3 version 1.40]]
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]
[[Category:ArmA 2: New Scripting Commands List|{{uc:{{PAGENAME}}}}]]

Latest revision as of 14:09, 27 November 2023

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).
Groups:
Multiplayer

Syntax

Syntax:
serverCommand command
Parameters:
command : String
Return Value:
Boolean - false if a non valid command is used ("#blah"), false otherwise (was always true before Arma 3 logo black.png1.40)

Alternative Syntax

Syntax:
password serverCommand command
Parameters:
password : String - case-sensitive password defined in server.cfg with serverCommandPassword param
command : String - server command
Return Value:
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";

Additional Information

See also:
serverCommandAvailable serverCommandExecutable admin isUIContext

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