addAction: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
(added known problems)
Line 57: Line 57:




An easy way to keep track of and remove actions is to set the ID of the action yourself.
An easy way to keep track of and remove actions is to store the IDs of the actions in variables. This can be accomplished by doing the following:
 
This can be accomplished by doing the following:


myaction = [[player]] '''addAction''' ["Hello", "hello.sqs"]
myaction = [[player]] '''addAction''' ["Hello", "hello.sqs"]


This sets the action's ID to "myaction".
This stores the action's ID in the global variable "myaction" and assists in keeping track of the action ID. To remove the above action, you would use the following line:
 
This can assist in keeping track of the action ID much easier.
 
To remove the above action, you would use the following line:


[[player]] [[removeAction]] myaction
[[player]] [[removeAction]] myaction
Line 75: Line 69:


This command, as well as configed actions, are executed only locally (not public).
This command, as well as configed actions, are executed only locally (not public).
'''Known Problems:'''
Due to a bug in OFP actions added via addAction don't get updated properly after mounting vehicles. When you have several actions available while mounting a vehicle and drive away from the actions' position, they'll still be shown in the menu until you dismount and remount the vehicle.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
There are work-arounds mentioned on the [http://www.ofpec.com/yabbse/index.php?board=8;action=display;threadid=23710 OFPEC Forums]

Revision as of 14:12, 24 May 2006


unit addaction action


Operand types:

unit: Object
action: Array

Type of returned value:

Nothing

Compatibility:

Added in version 1.10

Description:

Create an action.
Action ID should be returned, but due to bug it is not.
To determine action ID use following algorithm:
First action added to given vehicle has ID zero, next has ID 1, etc.


Example:

player addAction ["Hello", "hello.sqs"]


Comments:

It seems that since version 1.85+(?) addAction has correctly returned action ID.

Params passed by an action to the executed script:

[(object action was attached to), (unit that activated action), (index of action)]


So an example of an action-based script goes like this:

_obj = _this select 0

_man = _this select 1

_index = _this select 2


If you want to remove the action from the object immediately after it's triggered, use this line along with the above:

_obj removeAction _index


An easy way to keep track of and remove actions is to store the IDs of the actions in variables. This can be accomplished by doing the following:

myaction = player addAction ["Hello", "hello.sqs"]

This stores the action's ID in the global variable "myaction" and assists in keeping track of the action ID. To remove the above action, you would use the following line:

player removeAction myaction


MP Note:

This command, as well as configed actions, are executed only locally (not public).


Known Problems:

Due to a bug in OFP actions added via addAction don't get updated properly after mounting vehicles. When you have several actions available while mounting a vehicle and drive away from the actions' position, they'll still be shown in the menu until you dismount and remount the vehicle.

There are work-arounds mentioned on the OFPEC Forums