Jump to content
pappagoat

Arrays to randomly select object by object name?

Recommended Posts

I have a selection of 4 helicopters already in the map (heli1, heli2, heli3, heli4) I want to create an array to randomly select one of those existing helicopters.

 

Any help? I have not been able to get an array to work yet on object names.

Share this post


Link to post
Share on other sites
ppg_yourHelis = [];

{

private _name = str _x;

if ( _name select [0,3] == "heli" ) then { ppg_yourHelis pushBack _x; };

nil;

} count vehicles;

Now ppg_yourHelis contains [hel1, heli2, heli3, heli4]

 

And with this you can select one of these:

private _oneHeli = selectRandom ppg_yourHelis;

 

Share this post


Link to post
Share on other sites
47 minutes ago, davidoss said:

_selectedHeli = selectrandom [heli1, heli2, heli3, heli4];

 

 

Wow, thanks, that was simple and works beautifully.

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

×