serverCommand: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - " <dl class="command_description"> </dl>" to "")
(formatting)
Line 1: Line 1:
{{RV|type=command
{{RV|type=command


| arma2
|game1= arma2


|1.05
|version1= 1.05
 
|game2= arma2oa
 
|version2= 1.51
 
|game3= tkoh
 
|version3= 1.00
 
|game4= arma3
 
|version4=  0.50


|gr1= Multiplayer
|gr1= Multiplayer


| Executes the given [[Multiplayer_Server_Commands|server command]].
|descr= Executes the given [[Multiplayer_Server_Commands|server command]].
* Available commands for execution can be found with [[serverCommandAvailable]].
* Available commands for execution can be found with [[serverCommandAvailable]].
* Commands that can be executed can be found with [[serverCommandExecutable]].
* Commands that can be executed can be found with [[serverCommandExecutable]].


{{Feature | 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]]).}}
|pr= {{Feature | 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).}}
|s1 [[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"))
|r1 [[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}} {{Icon|serverExec|32}}
|s2= password [[serverCommand]] command {{GVI|arma3|1.40|y}} {{Icon|serverExec|32}}


|p21= password : [[String]] - password defined in [[server.cfg]] with <tt>serverCommandPassword</tt> param
|p21= password : [[String]] - password defined in [[server.cfg]] with <tt>serverCommandPassword</tt> param
|p22= command : [[String]] - server command
|p22= command : [[String]] - server command


Line 29: Line 40:


|x1= <code>[[serverCommand]] "#logout";</code>
|x1= <code>[[serverCommand]] "#logout";</code>
|x2= Create button on the main map which will show userlist to anyone who clicks on it:
|x2= Create button on the main map which will show userlist to anyone who clicks on it:
<code>[[with]] [[uiNamespace]] [[do]]  
<code>[[with]] [[uiNamespace]] [[do]]  
Line 41: Line 53:
}];
}];
};</code>
};</code>
|x3 = <code>[[serverCommand]] [[format]] ["#kick %1",_name];</code>
|x3 = <code>[[serverCommand]] [[format]] ["#kick %1",_name];</code>
|x4 = <code>_passwordWasOK = "MyServerCommandPassword" [[serverCommand]] "#lock";</code>
|x4 = <code>_passwordWasOK = "MyServerCommandPassword" [[serverCommand]] "#lock";</code>


|seealso= [[serverCommandAvailable]], [[serverCommandExecutable]], [[admin]], [[isUIContext]]
|seealso= [[serverCommandAvailable]], [[serverCommandExecutable]], [[admin]], [[isUIContext]]
}}
}}
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]
{{GameCategory|arma2|Scripting Commands}}
{{GameCategory|arma3|Scripting Commands}}
{{GameCategory|tkoh|Scripting Commands}}

Revision as of 10:38, 12 March 2021

Hover & click on the images for description

Description

Description:
Executes the given server command.
Problems:
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:
Syntax needed
Parameters:
command : String
Return Value:
Return value needed

Alternative Syntax

Syntax:
password serverCommand command Arma 3 logo black.png1.40 SEServer
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