Jump to content
Sign in to follow this  
f2k sel

Naming a spawmed group problem

Recommended Posts

look at your code again. Ontime you use _grp, the other time you use _group. Fix that and it should work as expected. :)

Share this post


Link to post
Share on other sites

Use this for the function:-

Get rid of _createMyGroup = { and the last bracket }.

"createMyGroup.sqf":-

private ["_grp","_unit"];

_grp = createGroup East;

_unit = _grp createUnit ["TK_Soldier_SL_EP1", [(getMarkerPos "pawn1") select 0,(getMarkerPos "pawn1") select 1,0], [], 3, "FORM"];
_unit = _grp createUnit ["TK_Soldier_GL_EP1", [(getMarkerPos "pawn1") select 0,(getMarkerPos "pawn1") select 1,0], [], 3, "FORM"];
_unit = _grp createUnit ["TK_Soldier_EP1", [(getMarkerPos "pawn1") select 0,(getMarkerPos "pawn1") select 1,0], [], 3, "FORM"];
_unit = _grp createUnit ["TK_Soldier_EP1", [(getMarkerPos "pawn1") select 0,(getMarkerPos "pawn1") select 1,0], [], 3, "FORM"];
_unit = _grp createUnit ["TK_Soldier_EP1", [(getMarkerPos "pawn1") select 0,(getMarkerPos "pawn1") select 1,0], [], 3, "FORM"];

_grp

What you have would work (with a few minor changes) if you used:-

#INCLUDE "createMyGroup.sqf"

at the top of your init.sqf.... or included the actual code in the file where it is called from (init.sqf). Then you would have been able to call the function.

Edited by twirly
Clarity

Share this post


Link to post
Share on other sites

Thanks guys but it still won't work.

I now get a preprocessor failure on file ect.

Share this post


Link to post
Share on other sites

F2K.... I had tested. Here are my files:-

init.sqf:-

waitUntil { !isNil "BIS_fnc_init" };
createMyGroup  = compile preprocessFile "createMyGroup.sqf";
sleep 1;
_grp = [] call createMyGroup;
hint format ["_grp: %1",_grp];

createmygroup.sqf:-

private ["_grp","_unit"];

_grp = createGroup East;

_unit = _grp createUnit ["TK_Soldier_SL_EP1", [(getMarkerPos "pawn1") select 0,(getMarkerPos "pawn1") select 1,0], [], 3, "FORM"];
_unit = _grp createUnit ["TK_Soldier_GL_EP1", [(getMarkerPos "pawn1") select 0,(getMarkerPos "pawn1") select 1,0], [], 3, "FORM"];
_unit = _grp createUnit ["TK_Soldier_EP1", [(getMarkerPos "pawn1") select 0,(getMarkerPos "pawn1") select 1,0], [], 3, "FORM"];
_unit = _grp createUnit ["TK_Soldier_EP1", [(getMarkerPos "pawn1") select 0,(getMarkerPos "pawn1") select 1,0], [], 3, "FORM"];
_unit = _grp createUnit ["TK_Soldier_EP1", [(getMarkerPos "pawn1") select 0,(getMarkerPos "pawn1") select 1,0], [], 3, "FORM"];

_grp

Can up a little demo if you need it. Let me know.

PS. I did notice you had a space in "createmygroup(space here).sqf" ..so check that.

Edited by twirly
Edited a mistake

Share this post


Link to post
Share on other sites

Cheers I noticed that thanks, All is working now.

However it's not quite what I was expecting.

I can see that as long as I change the grp = [] call createMyGroup; to something different each time I get a different named group which is ok but reading through Rubes post I thought I would be able to call the script several times and then use GRP as a pointer to each group, that's the bit I can't seem to figure.

Sorry if I'm not making sense.

Share this post


Link to post
Share on other sites

Hope I read you right but you can do something like:-

grplist = [];

for "_i" from 0 to 4 do {

      [s]_grpnam = format ["grp_%1",_i][/s];
      [s]_grpnam = [] call createMyGroup[/s];
      [s]_grplist set [count _grplist, _grpnam][/s];

      call compile format ["grp_%1 = [] call createMyGroup;",_i];
      hint format ["grp_%1",_i];
      call compile format ["_grplist set [count _grplist, grp_%1]",_i];

      sleep 0.01;
};

hint format ["_grplist:\n%1",_grplist];

Which will (tested) give you an array.... [grp_0,grp_1,grp_2,grp_3,grp_4];

The array is actually not necessary.... it's just included so that the names can be displayed after with hint.

You should be able now to refer to those groups from anywhere.

EDIT: I found that the names displayed in the hint are the usual Arma 2 groupnames. But using grp_1, grp_2 etc will also work.

Edited by twirly
Clarity

Share this post


Link to post
Share on other sites

Actually I miss read Rubes earlier post and you got it working as it should have worked.

That last bit will take some understanding, I take it it's making a dynamic name and placing them in an array. That would be useful if making loads of similar groups.

Thanks Twirly.

Share this post


Link to post
Share on other sites

Mate ... it appears I gave you some bogus code above. It was worrying me.... so I tested and fixed it. So changes made to code above. All is good now.

I take it it's making a dynamic name and placing them in an array.

Spot on man! Dynamically named groups.

Edited by twirly
Added info.

Share this post


Link to post
Share on other sites

Thanks again I'll take a look when I've had some sleep.

Share this post


Link to post
Share on other sites

Hahaha... I understand 100%. Take it easy Bro.

Share this post


Link to post
Share on other sites

That worked Great Twirly.

So really all I need to create multiple named groups it this looped as many times as required.

call compile format ["grp_%1 = [] call createMyGroup;",_i];

Thanks again names have always been a pain to me..

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  

×