Jump to content
Sign in to follow this  
D. Patterson

Create Marker On Every Object in Radius.

Recommended Posts

I tried

_houseLoc = getMarkerPos "realtor" nearObjects ["Land_i_House_Big_01_V1_F", 5000];
{
_hsmrk = createMarkerLocal ["Marker",getPos _x];
_hsmrk setMarkerType "Select";
} 
forEach _houseLoc;

and it's only marking one house.

Share this post


Link to post
Share on other sites

Each marker needs its own unique name.

Using _forEachIndex as part of the markers name would be a possible solution

_hsmrk = createMarkerLocal [format["myMarker_%1",_forEachindex],getPosASL _x];

Share this post


Link to post
Share on other sites

Conroy's method would work. However, if a similar loop is run again, it will overwrite all previous markers (due to using the same forEachIndex numbers).

A better solution would be to use the building ID (_x) as the marker name (as each building has a unique ID). Full code:

_houseLoc = getMarkerPos "realtor" nearObjects ["Land_i_House_Big_01_V1_F", 5000];
{
_hsmrk = createMarkerLocal [str(_x),getPos _x];
_hsmrk setMarkerType "Select";
} 
forEach _houseLoc;

str converts the building (_x) to a string.

Also, it would make more sense to rename _houseLoc to something like _nearHouses since the array doesn't return each house's location, it returns the object.

I hope this helps :)

Edited by Goodson

Share this post


Link to post
Share on other sites

Hello everybody,

Apologies for reopening an old thread. I was having the same problems as mcrow900.

I followed the steps as provides by MisterGoodson and it al works well.

_talke = _this select 0;

_objectLoc = nearestObjects [position _talke, ["Land_Pallets_F","ARP_Objects_IED","Land_Tyre_F","Land_MetalBarrel_F","Land_BarrelTrash_grey_F","Land_Sacks_heap_F","ARP_Objects_IED", "Land_GarbageBags_F", "Land_GarbageWashingMachine_F","Land_JunkPile_F"], 1000];

{
   _mrkr = createMarkerLocal [str(_x),getPos _x];
_mrkr setMarkerShape "ELLIPSE";
_mrkr setMarkerSize [200, 200];
_mrkr setMarkerColor "ColorRed";

} 
forEach _objectLoc;

I use this for marking IED locations (IED script : http://www.armaholic.com/page.php?id=23995) via an addaction.

However, now I'm trying to delete these markers once the IED are gone but I can't get it to work. How can I define these markers so I can delete them when I want?

Thanks in advance for the help.

Share this post


Link to post
Share on other sites

_talke = _this select 0; 

_objectLoc = nearestObjects [position _talke, ["Land_Pallets_F","ARP_Objects_IED","Land_Tyre_F","Land_MetalBarrel_F","Land_BarrelTrash_grey_F","Land_Sacks_heap_F","ARP_Objects_IED", "Land_GarbageBags_F", "Land_GarbageWashingMachine_F","Land_JunkPile_F"], 1000]; 
/* _markerArray = []; */

{
_mrkr = createMarkerLocal [str(_x),getPos _x];
_mrkr setMarkerShape "ELLIPSE";
_mrkr setMarkerSize [200, 200];
_mrkr setMarkerColor "ColorRed";

/* _markerArray pushBack _mrkr; */
} forEach _objectLoc;

5 months isn't that long but consider making your own thread in the future

Share this post


Link to post
Share on other sites

It'S untested

my idea is.

you need 2 arrays. The first one is a empty markerarray. The 2. is your objectLoc array.

After that, you fill the markerarray 1:1 with your obj array.

For every obj you add a eventhandler.

If this object killed, say

deletemarker -> select them from markerarray -> select postion in markerarray >> select the postion which the obj in his own array has (because it'S 1:1)

The selected one is a string.

mkrarray = [];
objectLoc = nearestObjects [position _talke, ["Land_Pallets_F","ARP_Objects_IED","Land_Tyre_F","Land_MetalBarrel_F","Land_BarrelTrash_grey_F","Land_Sacks_heap_F","ARP_Objects_IED", "Land_GarbageBags_F", "Land_GarbageWashingMachine_F","Land_JunkPile_F"], 1000];  
{ 
   _mrkr = createMarkerLocal [str(_x),getPos _x]; 
   _mrkr setMarkerShape "ELLIPSE"; 
   _mrkr setMarkerSize [200, 200]; 
   _mrkr setMarkerColor "ColorRed"; 
mkrarray = mkrarray + [_mrkr];
_x addeventhandler ["killed", {deleteMarker (mkrarray select (objectLoc select (_this select 0)) ) }];  
}  forEach objectLoc 

Edited by Drunken Officer

Share this post


Link to post
Share on other sites

Hello DreadedEntity and Drunken Officer,

Thanks for your responses. I tried both your suggestions and both did not have a positive result.

@DreadedEntity, I don't know how to delete the entries from the array.

I tried to google a answer for it, but I did not understand at all what I was reading about it.

I hope to tackle this problem one day soon though! But for now it already costed me too much time... :(

So for now I'm going with a far easier solution. Might not be pretty, but it works ;).

_talke = _this select 0; 
_IEDQ = (_this select 3) select 0; //IED question, will be one of different options via argument in addaction
_count = 0; 

if (_IEDQ) then 
{
_objectLoc = nearestObjects [position _talke,    ["Land_Pallets_F","ARP_Objects_IED","Land_Tyre_F","Land_MetalBarrel_F","Land_BarrelTrash_grey_F","Land_Sacks_heap_F","ARP_Objects_IED", "Land_GarbageBags_F", "Land_GarbageWashingMachine_F","Land_JunkPile_F"], 1000]; 
_count = count _objectLoc;

if (_count >= 1) then {hint "at least one IED";};
if (_count == 0) then {hint "No ied";};
};

Thanks you both for your time and effort.

Share this post


Link to post
Share on other sites

It's pretty straight forward deleting (all in this particular example) elements of an array with a forEach loop:

{deleteMarker _x} forEach _markerArray;

Now in your particular case you would probably want an alive check on the object the marker is attached to, if it's not alive delete the marker, if it is alive, do nothing.

You could also do a simple get/set variable attached to the objects and a "light" while loop spawned in the background checking that variable on each of the objects. And using a Killed EH (suggested by DrunkenOfficer) you could change the value of that variable, which in turn will delete the marker attached to that particular object in the event of it exploding in the next iteration of the while loop :).

Edited by JShock

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  

×