dga 12 Posted October 21, 2011 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
Muzzleflash 111 Posted October 21, 2011 _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
dga 12 Posted October 21, 2011 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
Muzzleflash 111 Posted October 21, 2011 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
dga 12 Posted October 21, 2011 (edited) 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 October 21, 2011 by dga Share this post Link to post Share on other sites
loyalguard 15 Posted October 21, 2011 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
dga 12 Posted October 21, 2011 (edited) 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 October 21, 2011 by dga Share this post Link to post Share on other sites
hellfire257 3 Posted October 21, 2011 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
dga 12 Posted October 22, 2011 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