Jump to content
Sign in to follow this  
jakkob4682

create an array of random locations from a count and then spawn objects at each loc?

Recommended Posts

have tried this, am I doing something wrong?

_loc = nearestLocation [player,"NameCity"];
_area = size (_loc);
_size = (_area select 1);

_roads = (position _loc) nearRoads _size;
_roadArray = [];
for "_i" from 1 to (round(floor(random _num))) do
{
_rng = _roads call BIS_fnc_selectRandom;
_rngPos = getPosATL _rng;
_roadArray set [(count _roadArray),_i];
};

{
_veh = _type createVehicle _x
}forEach _roadArray;

Share this post


Link to post
Share on other sites

Just some quick observations glancing at it without testing;

1) [player,"NameCity"] should probably be [getpos player,"NameCity"]

2) _num is not defined

3) I think size (_loc) returns a number value, not an array that can be selected from (meaning _area is not an array for _size to select from)

4) You must have a functions module if calling a function (dunno if you do or not, but just saying), and

5) Is _area returning a valid value? Because things appear dependent upon it.

Edited by OpusFmSPol
scrooged up the numbering

Share this post


Link to post
Share on other sites

size(_loc) returns an array, it is the size of the location, so yes _area would select the 2nd element in the size array. _num is just a tag I used for user defined number of positions to get. and yes I have a functions module present because when I use (round(floor(random _num - 1))) it doesnt seem to work. And yes you are correct nearestLocation uses a passed position [_pos,_params] that was my fault. Will test with [(getPosATL player,["NameCity"].

As far as location variables https://community.bistudio.com/wiki/Category:Command_Group:_Locations, that is where I am getting my information from for getting size,position,type etc

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  

×