Difference between revisions of "serverCommandAvailable"

From Bohemia Interactive Community
Jump to navigation Jump to search
(description example)
m
Line 7: Line 7:
 
____________________________________________________________________________________________
 
____________________________________________________________________________________________
  
| Returns [[true]] if the [[Multiplayer_Server_Commands|server command]] can be performed on the machine, [[false]] if not. Used in connection with [[serverCommand]].
+
| Returns [[true]] if the [[serverCommand]] can be performed on the machine, [[false]] if not. serverCommand can be executed only from [[User Interface Event Handlers]], so calling this command elsewhere may return true even if serverCommand would have no effect. |= Description
<br><br>
 
'''NOTE:''' This command must be executed from UI event handler ([[ctrlAddEventHandler]], [[displayAddEventHandler]]), such as ''onButtonDown'' or other [[User_Interface_Event_Handlers]]. |= Description
 
 
____________________________________________________________________________________________
 
____________________________________________________________________________________________
  
Line 20: Line 18:
 
|x1 = <code>_can = [[serverCommandAvailable]] "#kick";</code>
 
|x1 = <code>_can = [[serverCommandAvailable]] "#kick";</code>
 
|x2 = Add button to the main map to lock server, which could only be activated by admin:
 
|x2 = Add button to the main map to lock server, which could only be activated by admin:
<code>[[with]] [[uiNamespace]] [[do]] {
+
<code>
ctrl = [[findDisplay]] 12 [[ctrlCreate]] ["RscButton", -1];
+
[[if]] ([[serverCommandAvailable]] "#lock") [[then]] {
ctrl [[ctrlSetPosition]] [0,0,0.5,0.1];
+
[[serverCommand]] "#lock";
ctrl [[ctrlCommit]] 0;
+
} [[else]] {
ctrl [[ctrlSetText]] "LOCK SERVER";
+
[[hint]] "You need to be logged in as admin to do this";
ctrl [[ctrlAddEventHandler]] ["ButtonDown",
 
{
 
[[if]] ([[serverCommandAvailable]] "#lock") [[then]] {
 
[[serverCommand]] "#lock";
 
} [[else]] {
 
[[hint]] "You need to be logged in as admin to do this";
 
};
 
}];
 
 
};</code>
 
};</code>
| [[serverCommand]] |= See also
+
| [[serverCommand]], [[serverCommandExecutable]], [[Multiplayer Server Commands]] |= See also
  
 
}}
 
}}

Revision as of 10:10, 16 October 2014

Introduced with Arma 2 version 1.05
  

Click on the images for descriptions

Introduced in

Game:
Arma 2
Version:
1.05

Description

Description:
Returns true if the serverCommand can be performed on the machine, false if not. serverCommand can be executed only from User Interface Event Handlers, so calling this command elsewhere may return true even if serverCommand would have no effect.

Syntax

Syntax:
serverCommandAvailable command
Parameters:
command: String
Return Value:
Boolean

Examples

Example 1:
_can = serverCommandAvailable "#kick";
Example 2:
Add button to the main map to lock server, which could only be activated by admin: if (serverCommandAvailable "#lock") then { serverCommand "#lock"; } else { hint "You need to be logged in as admin to do this"; };

Additional Information

Multiplayer:
-
See also:
serverCommandserverCommandExecutableMultiplayer Server Commands

Notes

Only post proven facts here. Report bugs on the feedback tracker. Use the talk page or the forums for discussions.
Add New Note | How To

Notes

Bottom Section