darkiron 1 Posted April 8, 2014 I want to take all city in a script, how I can do this ? the result would like :{[pyrgos, 1.1133,15,111],...} Share this post Link to post Share on other sites
tpw 2315 Posted April 8, 2014 Not 100% sure that I understand what you want, but if you want to end up with an array (_cityarray) with all towns on the map in it then: _cityarray = []; _cities = nearestlocations [getpos player ,["namevillage","namecity","NameCityCapital"],20000]; // find all towns on map { _citypos = locationPosition _x _city = text _x; _cityarray set [count _cityarray, [_city,_citypos]]; } foreach _cities; Share this post Link to post Share on other sites
brians200 51 Posted April 8, 2014 (edited) Would it not be faster to look through the config, rather than searching for places? _placesCfg = configFile >> "CfgWorlds" >> worldName >> "Names"; _placesToKeep = ["NameCityCapital","NameCity","NameVillage"]; _places = []; for "_i" from 0 to (count _placesCfg)-1 do { _place = _placesCfg select _i; _name = toUpper(getText(_place >> "name")); _position = getArray (_place >> "position"); _type = getText(_place >> "type"); if(_type in _placesToKeep) then { _places set [_i, [_name, _position]]; }; }; Edited April 9, 2014 by brians200 Share this post Link to post Share on other sites
darkiron 1 Posted April 8, 2014 thanks for your answers !! Share this post Link to post Share on other sites
tpw 2315 Posted April 8, 2014 Would it not be faster to look through the config, rather than searching for places? _placesCfg = configFile >> "CfgWorlds" >> worldName >> "Names"; _placesToKeep = ["NameCityCapital","NameCity","NameVillage"]; _places = []; for "_i" from 0 to (count _placesCfg)-1 do { _place = _placesCfg select _i; _name = toUpper(getText(_place >> "name")); _position = getArray (_place >> "position"); _type = getText(_place >> "type"); if(_type in _placesToKeep) then _places set [_i, [_name, position]]; }; }; Nice one, might use that myself! Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted April 9, 2014 Nice one, might use that myself! Fixed the missing underscore and brackets: _placesCfg = configFile >> "CfgWorlds" >> worldName >> "Names"; _placesToKeep = ["NameCityCapital","NameCity","NameVillage"]; _places = []; for "_i" from 0 to (count _placesCfg)-1 do { _place = _placesCfg select _i; _name = toUpper(getText(_place >> "name")); _position = getArray (_place >> "position"); _type = getText(_place >> "type"); if(_type in _placesToKeep) then { _places set [_i, [_name, _position]]; }; }; Share this post Link to post Share on other sites
brians200 51 Posted April 9, 2014 That's what happens when you type code without trying it. Thanks Grumpy Old Man! Share this post Link to post Share on other sites