Continuing with addAction quirks, the 8th element in addAction params array is the condition statement. It has to return true in order for your custom action to show in action list. By default it always returns true. This condition is also evaluated every frame but there are certain rules to when it should be evaluated. You have to be closer than 15m to the object you added action to and you have to look at the object. If these 2 rules are met the condition script will run every frame for as long as you continue to look at the object and be close enough.
If you add an action to the player (yourself) you are obviously close enough to yourself and apparently are looking at yourself too, so condition is evaluated every frame all the time. Bear this in mind when adding action to player to avoid unnecessary CPU load. So nothing is new here, why is this useful?
This is huge in terms of its potential. You can arrange player interactions with surrounding objects at a very little cost. By simply adding specially crafted action to an object allows to execute scripts just when you are close enough to interact with objects and not before. For example you can create a trigger and attach it to an object and make it watch player, which is pretty good solution but not as efficient as using addAction. Of course you can just run while true loop with sleep and run nearObjects command with certain radius as a horrible horrible solution.
Other great feature that accompany this method is: Only one condition will be executed at any time, e.g. if you have 2 units close enough and looking at both only 1 unit’s action condition will be evaluated. I have constructed 2 simple scripts, one for player name tag showing over heads and another for doing the same for occupied vehicles. Both solutions, although maybe not the best looking, are extremely efficient.
So how such action needs to be constructed? For starters you can just fill first 7 params of addAction array with something, values don’t matter because we will never show the action anyway. Then for the 8th param, the code must return false to make sure the action doesn’t show, so the last line should always be false. Also note that while you can add action to many objects, in Arma 3 you cannot for example add action to animals. This is in fact intended.
Proof of concept #1 (Add tags to units):
Proof of concept #2 (Add tags to vehicles):