serverCommand: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - " <h3 style="display:none">Notes</h3>" to "") |
m (wording) |
||
(42 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
{{ | {{RV|type=command | ||
| arma2 | |game1= arma2 | ||
|version1= 1.05 | |||
|1. | |game2= arma2oa | ||
|version2= 1.50 | |||
|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]]. 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. | ||
{{ | {{Feature|informative| | ||
* Available commands for execution can be found with [[serverCommandAvailable]] | |||
* Commands that can be executed can be found with [[serverCommandExecutable]] | |||
}} | |||
{{Feature| | {{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]]).}} | ||
| [[serverCommand]] command | |s1= [[serverCommand]] command | ||
|p1= command : [[String]] | |p1= command : [[String]] | ||
| [[Boolean]] - | |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 | |||
|s2exec= server | |||
|s2since= arma3 1.40 | |||
|p21= password : [[String]] - case-sensitive password defined in [[Arma 3: Server Config File|server config]] with {{hl|serverCommandPassword}} param | |||
| | |p22= command : [[String]] - server command | ||
| | |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: | |x2= Create button on the main map which will show userlist to anyone who clicks on it: | ||
< | <sqf> | ||
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"; | |||
}]; | }]; | ||
};</ | }; | ||
|x3 = < | </sqf> | ||
|x4 = < | |||
|x3= <sqf>serverCommand format ["#kick %1",_name];</sqf> | |||
|x4= <sqf>private _passwordWasOK = "MyServerCommandPassword" serverCommand "#lock";</sqf> | |||
| [[serverCommandAvailable]] | |seealso= [[serverCommandAvailable]] [[serverCommandExecutable]] [[admin]] [[isUIContext]] | ||
}} | }} | ||
[[Category:Scripting Commands | [[Category:Scripting Commands: Server Execution]] | ||
[[Category:Introduced with Arma 3 version 1.40]] | |||
Latest revision as of 15:36, 29 October 2024
Description
- 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.
- 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 1.40)
- Syntax:
- password serverCommand command
- Parameters:
- password : String - case-sensitive password defined in server config 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:
- Example 4:
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
Categories:
- Scripting Commands
- Introduced with Arma 2 version 1.05
- Arma 2: New Scripting Commands
- Arma 2: Scripting Commands
- Arma 2: Operation Arrowhead: Scripting Commands
- Take On Helicopters: Scripting Commands
- Arma 3: Scripting Commands
- Command Group: Multiplayer
- Scripting Commands: Server Execution
- Introduced with Arma 3 version 1.40