Jump to content
Sign in to follow this  
dga

addAction Parameter becomes an array?

Recommended Posts

Hey there,

well I've got a really weird problem here and right now I don't know how to help myself out of this mess.

So there is a general question I need to get clarified.

In my init.sqf I spawn a group. After that I'm adding an action to the player, which will have the group to enter the vehicle (that code itself is working), but I got a weird problem with the addAction-Parametrers.

Init.sqf

...
_group = [getMarkerPos "aPos", WEST, 5] call BIS_fnc_spawnGroup;
player addAction["Move Squad into Heli", "Helpers\groupToVehicle.sqf",[_group]];

groupToVehicle.sqf

...
_group = _this select 3;
_leader = leader _group;

The weird thing is, that I get following error for the "leader _group"-thing ...

Error leader: Type Array, expected Object,Group,Team Member

If I do the "leader"-thing in my init.sqf it is fine. I am really on a rage on this right now *argh*

Why the hell is _group becoming an ARRAY?!? Did i miss something?

Thanks in advance,

dga

Share this post


Link to post
Share on other sites

_group is not becoming an array. You are however passing an array [_group] containing one item, _group, when you use the command addAction.

Share this post


Link to post
Share on other sites

yeah i'm aware of that, this is why i do

_group = _this select 3;

so I should have the single item of type group?

Share this post


Link to post
Share on other sites

When you add the action you specify [_group] as the "extra" argument to the handler script. The extra argument is in the third index of the _this array in your handler script thus:

_this select 3 <=> [_group]

If you wanted the extra argument to just be the group you should not wrap it in an array.

Share this post


Link to post
Share on other sites

Omg, now I got it.

so i gotta do

_args = _this select 3;
_group = _args select 0;

right?

Oh god, thank you.

Completely lost my mind while raging. Somehow I thougt the arguments-"array" will passed along as 3,4,5...etc.

Sometimes, you miss the simple things ;/

Edited by dga

Share this post


Link to post
Share on other sites

Even simpler than that is just to do this:

player addAction["Move Squad into Heli", "Helpers\groupToVehicle.sqf", _group];

This way you are not passing an array to groupToVehicle.sqf so you do not have to do select 3 and then select 0.

Share this post


Link to post
Share on other sites

Yeah, thanks, but I need to pass more stuff to the function, I just simplified the code for testing.

And I thought I get the other stuff by _this select 4, _this select 5 ...stupid somehow ^^ I'll call that a fail.

Edited by dga

Share this post


Link to post
Share on other sites

You should be able to do it...

//This is your array in the addAction params
_argumentsArray = _this select 3;

//The individual parts of the array
_argument0 = _argumentsArray select 0;
_argument1 = _argumentsArray select 1;
_argument2 = _argumentsArray select 2;

At least I think something like that should work.

Share this post


Link to post
Share on other sites

Thats what I did now. But thanks anyway.

Could be useful for the next "morron" like me :D

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  

×