Page tree
Skip to end of metadata
Go to start of metadata



Introduced in

Version:1.31

Description

Description:This function is similar to the addAction command, with the exception that the added action remains visible, if the unit gets into a vehicle (it is visible for both units inside and outside the vehicle).

Note: Special steps must be taken to remove actions added with this function:

  • They must be removed using fn vbs removeActionEx, not using the removeAction command.
  • You cannot use the (_this select 0) and (_this select 2) parameters passed to the action code to remove the action after it is used. These parameters refer to the object the action is attached to and the index of that action. The index is not the index returned by this function, and the object could be the unit if it is on foot, or it could be the unit vehicle.

Instead, you can pass the inputs required by fn vbs removeActionEx directly to the action script in the (_this select 3) variable.

In V2.0+, instead of the unit object, an array can be passed that contains [unit,id], where id is a unique number assigned to the added action. This prevents actions that have the same id from being listed multiple times, when several units with the same action are inside a vehicle (duplicate actions are still visible outside the vehicle).

The alternative syntax of this function can be used, to get the index of the action before you add it. The alternate syntax does not actually add any action to the unit, but returns the index of the next action to be added. You can then take this return value, and pass it to the action for use in the code.

Syntax

Syntax:[unit, [parameters]] call fn_vbs_addActionEx
Parameters:
Return Value:Number - Index of action (for use in fn vbs removeActionEx).

Alternative Syntax

Syntax:[unit] call fn_vbs_addActionEx
Parameters:
  • unit: Object - Unit to query (no action is added).
Return Value:Number - Index that is used by the next added action.

Warning

When using functions in VBS versions older than 3.4, certain limitations and requirements should be kept in mind - the main ones being that capitalization of the function name is crucial, and that #include "\vbs2\headers\function_library.hpp" has to be included in every script that utilizes it. More Category VBS Scripting Functions.

Examples

Examples:
// This action is only visible while player is on foot
_idx1 = player addAction ["My Action", "myaction.sqf"];
// This action is visible even when the player is in a vehicle
_idx2 = [player, ["My Action", "myaction.sqf"]] call fn_vbs_addActionEx;

sleep 60;

// This only works for actions added using addAction
player removeActon _idx1;
// This function must be used to remove actions added using fn_vbs_addActionEx
[player, _idx2] call fn_vbs_removeActionEx;
Self-removing action:
// Get the index of the action you want to add
_idx = [bob] call fn_vbs_addActionEx;

// Pass the index and unit to the action code, so that the action can remove itself after it is used
_params = ["myAction", "myaction.sqf", [bob, _idx]];
[player, _params] call fn_vbs_addActionEx;

myaction.sqf

//remove action that was just used
_actionUnit = (_this select 3) select 0;
_actionIdx = (_this select 3) select 1;
[_actionUnit, actionIdx] call fn_vbs_removeActionEx;
Actions with unique ID:
{
  [[_x,1],["ActionName", "action.sqf"]] call fn_vbs_addActionEx;
} forEach allUnits;

Additional Information

See also: fn vbs removeActionEx, addAction
Multiplayer:Actions added in this way have identical behavior to actions added using the addAction command.
Problems:Actions added in this way do not work with parachutes (which are considered a vehicle).

Notes