Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
eagledude4

calling functions from addaction

Recommended Posts

When I call a function in the _Code argument, it doesn't call the function when the action is activated

_Unit addAction [_Str, _Code, _Args, 1, false, true, "", _Condition];

The wiki doesn't say anything about calling functions, but I think the feature been present since OA.

Share this post


Link to post
Share on other sites

Just place the function name as the code.

_id = _unit addAction ["Name",Tag_fnc_myFunction,_arg];

Then the function with have the same parameters sent.

_target = _this select 0;
_caller = _this select 1;
_id = _this select 2;
_arg = _this select 3;

Share this post


Link to post
Share on other sites

That's what I'm doing. The action shows, but "TEST" is not displayed when I try to activate the action.

actions.sqf:

[player, "#FF8000", "TEST", "ED4_fnc_TEST", "", "AdminMode"] call ED4_fnc_addAction;

fn_addAction.sqf:

//By Eagledude4

_Unit = _this select 0;

_Color = _this select 1;
_actionStr = _this select 2;
_Str = format["<t color='%1'>%2</t>", _Color, _ActionStr];

_Code = _this select 3;
_Args = _this select 4;
_Condition = _this select 5;

_Unit addAction [_Str, _Code, _Args, 1, false, true, "", _Condition];

fn_TEST.sqf:

hint "TEST";

Share this post


Link to post
Share on other sites
That's what I'm doing. The action shows, but "TEST" is not displayed when I try to activate the action.

actions.sqf:

[player, "#FF8000", "TEST", "ED4_fnc_TEST", "", "AdminMode"] call ED4_fnc_addAction;

fn_addAction.sqf:

//By Eagledude4

_Unit = _this select 0;

_Color = _this select 1;
_actionStr = _this select 2;
_Str = format["<t color='%1'>%2</t>", _Color, _ActionStr];

_Code = _this select 3;
_Args = _this select 4;
_Condition = _this select 5;

_Unit addAction [_Str, _Code, _Args, 1, false, true, "", _Condition];

fn_TEST.sqf:

hint "TEST";

you are not doing it right. your action does not point to a function.

Edited by k0rd

Share this post


Link to post
Share on other sites

Function name should be code, not a string.

[player, "#FF8000", "TEST", ED4_fnc_TEST, "", "AdminMode"] call ED4_fnc_addAction;

Share this post


Link to post
Share on other sites

Hmm, haven't heard of that.

To be on the safe side, what stops you from simply putting the code for executing the function in it?

Like so:

_Unit addAction [_Str, {_this call _function;}, _Args, 1, false, true, "", _Condition];

Share this post


Link to post
Share on other sites

Some people do that as well. Though you might have to compile or format it to make it work across functions as a parameter like that.

Share this post


Link to post
Share on other sites
Sign in to follow this  

×