Comrades in Arms Discussion Board
Simple way to use addAction in MP - Printable Version

+- Comrades in Arms Discussion Board (http://forum.ciahome.net)
+-- Forum: Comrades in Arms Life (http://forum.ciahome.net/forumdisplay.php?fid=3)
+--- Forum: Mission Making (http://forum.ciahome.net/forumdisplay.php?fid=8)
+--- Thread: Simple way to use addAction in MP (/showthread.php?tid=2900)



Simple way to use addAction in MP - Outlawz7 - 02-09-2015

Here's a simple way to use addAction that works in MP and doesn't need much scripting or coding knowledge.

You'll need a named object or (nonplayable) unit and a trigger.

In your unit/object's init field (you can use object's name or 'this', since it's the object's init):
Code:
actionIDhandle = objectName addAction ["<t color='#FF0000'>Your action text here</t>",{myVariable = true; publicVariable "myVariable"; },nil,1,true,true,"","_target distance _this < 3"];

In short, this adds a variable to remove the action, transmits a public variable when activated and also ensures you can't see the action until you're less than 3m away from the object it's assigned to (bigger the object, larger the distance you can see addAction from).

In the trigger Condition line:
Code:
myVariable

Once the addAction is activated, myVariable will equal true and activate the trigger.

In the trigger Activation line:
Code:
objectName removeAction actionIDhandle;


Since the action was added everywhere (everyone loaded the same object with the same init when starting the mission) and the trigger exists everywhere, the trigger will activate and remove the action everywhere. You can add whatever else you want to do with addAction in the Activation line.

Read more:
https://community.bistudio.com/wiki/addAction

Tips:
You can use commands with global effect in the addAction's code line reliably, such as setDamage or deleteVehicle:
Code:
objectName addAction ["Delete me",{deleteVehicle (_this select 0)}]

Above action would delete the object it was added to, removing the need to use a ID handle as the unit no longer exists.


Re: Simple way to use addAction in MP - Alwarren - 02-09-2015

Let me add to this that addAction has local effect. That means if you want to add the action later (i.e. not in the init field), you need to actually run it on all clients, for example via BIS_fnc_MP.

As usual when doing anything with global effect, watch for duplication effects. Refer to this guide for more information on that


Re: Simple way to use addAction in MP - Imperator - 02-10-2015

Alwarren you mentioned that there were some addAction issues in my mission CiA recently played.  Could you expand on that a bit more if possible please?

Did the addAction not show up for some players?


Re: Simple way to use addAction in MP - Variable - 02-10-2015

(02-10-2015, 06:38 AM)Imperator link Wrote:Alwarren you mentioned that there were some addAction issues in my mission CiA recently played.  Could you expand on that a bit more if possible please?

Did the addAction not show up for some players?
See here Imperator: http://ciahome.net/forum/mission-making/simple-way-to-use-addaction-in-mp/