Jump to content
Sign in to follow this  
darkiron

grab all city place ?

Recommended Posts

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

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

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 by brians200

Share this post


Link to post
Share on other sites
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
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

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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×