Jump to content
Sign in to follow this  
joikd

Instead of nearObjects how to get all objects

Recommended Posts

Vanilla working code is this:

_position = getPosATL player;
_nearby = _position nearObjects ["building",200];

So, this appears to get the position of the player, then all of the "building"s within 200 of that player's position.

How would I get all of the "building"s that are on the map (every single one--not just within 200) in a similar format as nearObjects without having a player's position to use as a reference point? Any help would be greatly appreciated.

Share this post


Link to post
Share on other sites

Put a marker named "myMapCenter". near the center of your map.

Then:

_nearby = (getMarkerPos "myMapCenter") nearObjects ["building",20000];

if the map is bigger than 20 clicks then just bump up the distance.

Share this post


Link to post
Share on other sites

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

I've never used this so am not sure if it will get map opbjects. It seems to suggest it will only get objects created by the editor and possibly in script.

Both this and a nearobjects with a large radius are going to be very CPU intensive. Use with care.

Share this post


Link to post
Share on other sites

Thanks a million, gents. I will give these a try. Only using once upon server start, so should be okay CPU-wise I think.

Share this post


Link to post
Share on other sites

Don't bother with the marker:

_center = getArray(configFile >> "CfgWorlds" >> _worldName >> "centerPosition";

where _worldName is your map name (eg.: Chernarus)

Share this post


Link to post
Share on other sites
Don't bother with the marker:

_center = getArray(configFile >> "CfgWorlds" >> _worldName >> "centerPosition";

where _worldName is your map name (eg.: Chernarus)

Yes that does work, but the problem is that its not always in the right spot, and some map makes don't even define it at all in there configs.

My solution will always work even on custom maps that do not have all the location data configured.

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  

×