serverCommandAvailable: Difference between revisions
Jump to navigation
Jump to search
m (Text replace - "{{uc:{{PAGENAME}}}}" to "{{uc:{{PAGENAME}}}} {{uc:{{PAGENAME}}}}") |
Killzone Kid (talk | contribs) (description example) |
||
Line 7: | Line 7: | ||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
| Returns [[true]] if the [[Multiplayer_Server_Commands| | | Returns [[true]] if the [[Multiplayer_Server_Commands|server command]] can be performed on the machine, [[false]] if not. Used in connection with [[serverCommand]]. | ||
<br><br> | |||
'''NOTE:''' This command must be executed from UI event handler ([[ctrlAddEventHandler]], [[displayAddEventHandler]]), such as ''onButtonDown'' or other [[User_Interface_Event_Handlers]]. |= Description | |||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
| | | '''serverCommandAvailable''' command |= Syntax | ||
|p1= command: [[String]] |= Parameter 1 | |p1= command: [[String]] |= Parameter 1 | ||
Line 16: | Line 18: | ||
| [[Boolean]] |= Return value | | [[Boolean]] |= Return value | ||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
|x1 = <code> _can < | |x1 = <code>_can = [[serverCommandAvailable]] "#kick";</code> | ||
|x2 = Add button to the main map to lock server, which could only be activated by admin: | |||
<code>[[with]] [[uiNamespace]] [[do]] { | |||
ctrl = [[findDisplay]] 12 [[ctrlCreate]] ["RscButton", -1]; | |||
ctrl [[ctrlSetPosition]] [0,0,0.5,0.1]; | |||
ctrl [[ctrlCommit]] 0; | |||
ctrl [[ctrlSetText]] "LOCK SERVER"; | |||
ctrl [[ctrlAddEventHandler]] ["ButtonDown", | |||
{ | |||
[[if]] ([[serverCommandAvailable]] "#lock") [[then]] { | |||
[[serverCommand]] "#lock"; | |||
} [[else]] { | |||
[[hint]] "You need to be logged in as admin to do this"; | |||
}; | |||
}]; | |||
};</code> | |||
| [[serverCommand]] |= See also | | [[serverCommand]] |= See also | ||
Revision as of 19:13, 14 October 2014
Description
- Description:
- Returns true if the server command can be performed on the machine, false if not. Used in connection with serverCommand.
NOTE: This command must be executed from UI event handler (ctrlAddEventHandler, displayAddEventHandler), such as onButtonDown or other User_Interface_Event_Handlers. - Groups:
- Uncategorised
Syntax
Examples
- Example 1:
_can = serverCommandAvailable "#kick";
- Example 2:
- Add button to the main map to lock server, which could only be activated by admin:
with uiNamespace do { ctrl = findDisplay 12 ctrlCreate ["RscButton", -1]; ctrl ctrlSetPosition [0,0,0.5,0.1]; ctrl ctrlCommit 0; ctrl ctrlSetText "LOCK SERVER"; ctrl ctrlAddEventHandler ["ButtonDown", { if (serverCommandAvailable "#lock") then { serverCommand "#lock"; } else { hint "You need to be logged in as admin to do this"; }; }]; };
Additional Information
- See also:
- serverCommand
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