Jump to content
Sign in to follow this  
1para{god-father}

Spawn using Array

Recommended Posts

I generate some random markers then add the pos to an array , now i need to place men in those marker but how do I do that using my Array, thought the belkow would work but not as they all spawn on the same spot :(

i.e Missionmarkers= [[1550,5650,0],[1650,5750,0],[1250,5850,0],[1250,5850,0],[1650,5650,0],[1450,5850,0]]


_count = count Missionmarkers;
_markertemp = Missionmarkers;

for "_i" from 1 to _count do {
    _spawngroup = [_markertemp select 0, EAST, ["TK_INS_Soldier_MG_EP1"], [],[],[],[],[1,1]] call BIS_fnc_spawnGroup;
    _markertemp = _markertemp - [_markertemp select 0];
};


Share this post


Link to post
Share on other sites
_markertemp select 0

Always 0, swap it to a floor(ed) random of the size of the array or use the loops "_i".

Share this post


Link to post
Share on other sites

I suppose, it is because you try to subtract nested array (position) from an array. This wouldn't work. Here, at the end of the article, is workaround for that:

http://community.bistudio.com/wiki/Array

PS BTW with another loop you can avoid subtracting at all, for example something like this:

_count = count Missionmarkers;
_markertemp = Missionmarkers;

for "_i" from 0 to (_count - 1) do
{
_spawngroup = [_markertemp select _i, EAST, ["TK_INS_Soldier_MG_EP1"], [],[],[],[],[1,1]] call BIS_fnc_spawnGroup;
};

Edited by Rydygier

Share this post


Link to post
Share on other sites
I suppose, it is because you try to subtract nested array (position) from an array. This wouldn't work. Here, at the end of the article, is workaround for that:

http://community.bistudio.com/wiki/Array

PS BTW with another loop you can avoid subtracting at all, for example something like this:

_count = count Missionmarkers;
_markertemp = Missionmarkers;

for "_i" from 0 to (_count - 1) do
{
_spawngroup = [_markertemp select _i, EAST, ["TK_INS_Soldier_MG_EP1"], [],[],[],[],[1,1]] call BIS_fnc_spawnGroup;
};

Ahhh that is better way of doing it !

Thanks

Share this post


Link to post
Share on other sites

Yup, foreach is much better. No need for count or a loop.

Share this post


Link to post
Share on other sites
Why not loop forEaches on single value arrays?

While counting the forEachIndexes sum?

Share this post


Link to post
Share on other sites
While counting the forEachIndexes sum?

What are you guys talking about or are these jokes that I am not getting!!??

Share this post


Link to post
Share on other sites
What are you guys talking about or are these jokes that I am not getting!!??

Horrible jokes you should proud you didn't get. :)

Share this post


Link to post
Share on other sites

Tried this way?

    {
   _spawngroup = [_x, EAST, ["TK_INS_Soldier_MG_EP1"], [],[],[],[],[1,1]] call BIS_fnc_spawnGroup;
   }
foreach Missionmarkers

Really doesn't matter, which loop you choose. Matters, if code does, what you want.

Edited by Rydygier

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  

×