D. Patterson 14 Posted July 15, 2014 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
conroy 13 Posted July 15, 2014 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
Gudsawn 93 Posted July 15, 2014 (edited) 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 July 15, 2014 by Goodson Share this post Link to post Share on other sites
Tiberius_161 41 Posted December 29, 2014 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
dreadedentity 278 Posted December 29, 2014 _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
drunken officer 18 Posted December 29, 2014 (edited) 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 December 29, 2014 by Drunken Officer Share this post Link to post Share on other sites
Tiberius_161 41 Posted December 29, 2014 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
jshock 513 Posted December 30, 2014 (edited) 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 December 30, 2014 by JShock Share this post Link to post Share on other sites