Jump to content
Sign in to follow this  
=101AD=Richard

Add action help

Recommended Posts

How can I add this to a flag so you can select it instead of just walking into a trigger and activating the script

nul=[] execVM "popupA2.sqf"

Share this post


Link to post
Share on other sites

this addaction ["Activate Target","popup2a.sqf"] placed in the flag poles init.

Share this post


Link to post
Share on other sites

Red = group this place in the leaders init the group would then be Red

Share this post


Link to post
Share on other sites
Red = group this place in the leaders init the group would then be Red

Works for any unit, not necessarily leader

Share this post


Link to post
Share on other sites

Can you call a function with addAction?

mf = player addaction ["Set FOB Location","call fnc_CWO_FOB"];

Share this post


Link to post
Share on other sites

Not directly, but indirectly:

action.sqf

private ["_t","_c","_i","_a"];
_t = _this select 0;
_c = _this select 1;
_i = _this select 2;
_a = _this select 3;

if (typename _a == typename []) then {
 [_t,_c,_i,(_a select 0)] spawn (_a select 1);
} else {
 [_t,_c,_i] spawn _a;
};

mf = player addaction ["Set FOB Location","action.sqf",{call fnc_CWO_FOB}];

Share this post


Link to post
Share on other sites

Since action needs to be given as a script name, we make a script that takes any code as parameter and runs it.

Example:

this addaction ["actionName","action.sqf",{hint "hello world"}];

Using the action, script action.sqf is started and code hint hello world is sent to it as parameter. The script runs that code, as if the script contained: hint hello world. Passing it as code saves as the trouble of creating multiple scripts, thanks to reusability of action.sqf.

Example with parameter:

this addaction ["actionName","action.sqf",["there",{hint format ["hello %1",(_this select 3)]}]];

Same as the first example, but this time we pass an parameter as well as the code. Result is hint with "hello there".

Share this post


Link to post
Share on other sites

Thanks.

Works like a charm.

Can I ask for a little more explanation on action.sqf?

Why are so many parameters ["_t","_c","_i","_a"] , when it seems only the last one is used(_a)?

In this example:

 mf = player addaction ["Set FOB Location","action.sqf",{call fnc_CWO_FOB}];

What's the breakdown of the code into the different parameters?

Edited by Two Dogs

Share this post


Link to post
Share on other sites

They are the parameters that action (addAction) passes to the script, they are just passed onwards to the given code.

_t == _target, object to which the action is added to

_c == _caller, who used the action

_i == _id, action number, can be used to remove the action

Your own parameters will be in the (_this select 3), just like they would be in a "normal" action script.

Share this post


Link to post
Share on other sites

fobaction = veh1 addaction [("<t color=""#8A0886"">" + ("Set Rallypoint Location") + "</t>"),"action.sqf",{[b]player call fnc_CWO_RP[/b]}];

OK, this is what I'm tying to do, but I'm not sure how I would apply this to the action.sqf, or if it's appropriate.

Share this post


Link to post
Share on other sites

Missing a ; in the line above. Works fine.

Thank you very much.

You are patient and wise.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×