action: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
No edit summary
Line 52: Line 52:
|x2= <code>_soldier [[action]] ["Eject", [[vehicle]] _soldier];</code>
|x2= <code>_soldier [[action]] ["Eject", [[vehicle]] _soldier];</code>


|x3= <code>[[action]] ["UseWeapon", [[player]], [[player]], 7];</code>
|x3= <code>[[player]] [[action]] ["UseWeapon", [[player]], [[player]], 7]; //-- plays pick up action before throwing grenade
[[action]] ["UseWeapon", [[player]], [[player]], 7]; //-- normal grenade throw</code>


|seealso= [[actionIDs]] [[actionParams]] [[addAction]] [[setUserActionText]] [[inGameUISetEventHandler]] [[showHUD]] [[inputAction]] [[removeAction]] [[removeAllActions]]
|seealso= [[actionIDs]] [[actionParams]] [[addAction]] [[setUserActionText]] [[inGameUISetEventHandler]] [[showHUD]] [[inputAction]] [[removeAction]] [[removeAllActions]]

Revision as of 21:11, 29 March 2022

Hover & click on the images for description

Description

Description:
Make a unit perform an action. See Category:Actions for action names and syntaxes.
The argument's locality is usually local, but some actions can take a global argument (e.g "Eject", "GetOut", "GetInXXXX", "MoveToXXXX"). See Category:Actions for more details.
In Singleplayer, when user Alt-Tabs the simulation is paused and so the action will also halt until user returns to the game. For example, player action ["GetInDriver", car]; executed while user is Alt-Tabbed will result in the user seeing the action happening when he returns to the game screen. This doesn't happen in Multiplayer.
Alternative syntax of the command is introduced with Arma 3 v2.09.149165 creates a temporary Logic entity in place of 'unit' argument (See Category:Actions for benefits of using Logic)
Groups:
Interaction

Syntax

Syntax:
unit action actionArray
Parameters:
unit: Object
actionArray: Array
Return Value:
Nothing

Alternative Syntax

Syntax:
action actionArray
Parameters:
actionArray: Array
Return Value:
Nothing

Examples

Example 1:
player action ["SitDown", player];
Example 2:
_soldier action ["Eject", vehicle _soldier];
Example 3:
player action ["UseWeapon", player, player, 7]; //-- plays pick up action before throwing grenade action ["UseWeapon", player, player, 7]; //-- normal grenade throw

Additional Information

See also:
actionIDs actionParams addAction setUserActionText inGameUISetEventHandler showHUD inputAction removeAction removeAllActions

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
Posted on 28 Aug, 2009
tom_48_97
In Arma 2, you can place a unique unit (for example a boat, far of all combats) and use it for all command lines with action.
Posted on March 27, 2015 - 17:57 (UTC)
DreadedEntity
This command has no effect when a dead unit is used as input.
Posted on June 27, 2017 - 02:15 (UTC)
DrSova
player action ["SWITCHWEAPON", player, player, -1] Switching weapon to the back.
Posted on July 20, 2017 - 12:22 (UTC)
Yuval
Some of the actions (such as "DropWeapon") do not always execute, and there should be a set of conditions for them to run. The unit must be able to perform the dropping animation in order for the action to properly execute. So, if for example we spawn a unit at [0,0,0] and make it perform a "DropWeapon" action - it won't work if [0,0,0] is water (which it is, if the current map is an island) because the unit will be swimming.

Also, you cannot stack up actions right after the other. If you run a "DropWeapon" action when the current action animation is still going - it will not perform. There are a few more conditions for an action to perform, but relying on a hundred percent success of the action is not a good practice.