serverCommand: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\|x([0-9])= *<code>([^<]*)<\/code>" to "|x$1= <sqf>$2</sqf>")
m (wording)
 
(10 intermediate revisions by 5 users not shown)
Line 15: Line 15:
|gr1= Multiplayer
|gr1= Multiplayer


|descr= 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|
{{Feature|informative|
* Available commands for execution can be found with [[serverCommandAvailable]]
* Available commands for execution can be found with [[serverCommandAvailable]]
Line 21: Line 22:
}}
}}


{{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]]).}}
{{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
|s1= [[serverCommand]] command
Line 27: Line 28:
|p1= command : [[String]]
|p1= command : [[String]]


|r1= [[Boolean]] - always [[true]] for some reason (since {{arma3}} v1.39 also [[false]] if a non valid command is used ("#blah"))
|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 {{Icon|serverExec|32}}
|s2= password [[serverCommand]] command
|s2exec= server


|s2since= arma3 1.40
|s2since= arma3 1.40


|p21= password : [[String]] - password defined in [[server.cfg]] with {{hl|serverCommandPassword}} param
|p21= password : [[String]] - case-sensitive password defined in [[Arma 3: Server Config File|server config]] with {{hl|serverCommandPassword}} param


|p22= command : [[String]] - server command
|p22= command : [[String]] - server command


|r2= [[Boolean]] - [[true]] if password is correct
|r2= [[Boolean]] - [[false]] if command failed at some stage. [[true]] doesn't mean that command succeeded.


|x1= <sqf>serverCommand "#logout";</sqf>
|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:
<code>with uiNamespace do  
<sqf>
with uiNamespace do  
{
{
private _ctrl = findDisplay 12 ctrlCreate ["RscButton", -1];
private _ctrl = findDisplay 12 ctrlCreate ["RscButton", -1];
Line 52: Line 55:
serverCommand "#userlist";
serverCommand "#userlist";
}];
}];
};</code>
};
</sqf>


|x3= <sqf>serverCommand format ["#kick %1",_name];</sqf>
|x3= <sqf>serverCommand format ["#kick %1",_name];</sqf>

Latest revision as of 15:36, 29 October 2024

Hover & click on the images for description

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.
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 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:
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