Barba-negra 117 Posted April 27, 2018 good afternoon all, I come here asking for help please, I'm trying to make it through a scripts, show me on the map in a specific radius, the position of an object with a marker nearestObjects [player, ["Land_waterbarrel_F"], 200]; marker1 = createMarker ["Marker1", position _Land_waterbarrel_F]; but I have not made it work, what am I doing wrong? please help Share this post Link to post Share on other sites
Harzach 2516 Posted April 27, 2018 18 minutes ago, elthefrank said: marker1 = createMarker ["Marker1", position _Land_waterbarrel_F]; You have an errant underscore in your createMarker line. There's more, but I'm in the middle of something, back in a few minutes. 2 Share this post Link to post Share on other sites
Barba-negra 117 Posted April 27, 2018 good afternoon Arzach, if I must have several bad things, I really can not do this, I think the scripts is incomplete Share this post Link to post Share on other sites
Harzach 2516 Posted April 27, 2018 (edited) OK, here is something that works: _barrels = nearestObjects [player, ["Land_BarrelWater_F"], 200]; if (count _barrels > 0) then { _mrk = createMarker ["Marker1", position (_barrels select 0)]; _mrk setMarkerShape "ICON"; _mrk setMarkerType "hd_dot"; }; This will place a black mildot on the nearest object of class "Land_BarrelWater_F", if there is at least one within 200 meters. If you want to reference the array returned by nearestObjects, you must add a handle (_barrels in my example). You had the classname wrong. To use createMarker, you must define name/pos, shape, and type at the very least. If you want to place a marker on EVERY barrel within 200 meters, you can do something like this: _barrels = nearestObjects [player, ["Land_BarrelWater_F"], 200]; if (count _barrels > 0) then { _name = "Marker" + str (random 10000); _pos = position _x; _mrk = createMarker [_name, _pos]; _mrk setMarkerShape "ICON"; _mrk setMarkerType "hd_dot"; } forEach _barrels; Do you need to manipulate the markers further after creation? For example, move them or delete them? Edited April 27, 2018 by Harzach added non-zero check, thanks HazJ ;) 2 Share this post Link to post Share on other sites
Barba-negra 117 Posted April 27, 2018 ohh great Harzach, thanks for helping me, yes, the idea would be that after they are destroyed the markers disappear Share this post Link to post Share on other sites
HazJ 1289 Posted April 27, 2018 If no objects are found, that code may error. Sometimes best to add a safe check. if (count _barrels > 0) then { // code... }; You can also use selectRandom instead of first found. _mrk = createMarker ["Marker1", getPos (selectRandom _barrels)]; 1 1 Share this post Link to post Share on other sites
Harzach 2516 Posted April 27, 2018 10 minutes ago, elthefrank said: ohh great Harzach, thanks for helping me, yes, the idea would be that after they are destroyed the markers disappear That will add another level or two of complexity, but it can certainly be done. I might be able to work on it later tonight, but there are other helpful folks here, too :) 1 Share this post Link to post Share on other sites
HazJ 1289 Posted April 27, 2018 Use Killed EH. https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#Killed 1 Share this post Link to post Share on other sites
Barba-negra 117 Posted April 27, 2018 good afternoon HazJ, guys laverdad I do not know what I'll be doing wrong, hie the following and still does not show me the marker near the object: Call the scripts through a alpha radio trigger: 0 = [] execVM "detector.sqf"; inside the detector scripts place the script: _barrels = nearestObjects [player, ["Land_BarrelWater_F"], 200]; { _name = "Marker" + str (random 10000); _pos = position _x; _mrk = createMarker [_name, _pos]; _mrk setMarkerShape "ICON"; _mrk setMarkerType "hd_dot"; } forEach _barrels; then in the editor I placed a Land_WaterBarrel_F object near the player, and when I called it the scripts with the trigger did not show me the mark on the map, what would I do wrong? Share this post Link to post Share on other sites
HazJ 1289 Posted April 27, 2018 What is laverdad? Try this: _barrels = nearestObjects [player, ["Land_BarrelWater_F"], 200]; if (count _barrels > 0) then { { _pos = getPos _x; _mrk = createMarker [format ["barrel%1Mkr", (_forEachIndex + 1)], _pos]; // so it starts from barrel1Mkr and not barrel0Mkr _mrk setMarkerShape "ICON"; _mrk setMarkerType "hd_dot"; } forEach _barrels; } else { hintSilent "No nearby barrels found"; }; Should work. Or show hint if no barrels found. This won't work for map objects. For that use: https://community.bistudio.com/wiki/nearestTerrainObjects _barrels = nearestTerrainObjects [player, ["Land_BarrelWater_F"], 200]; 1 1 Share this post Link to post Share on other sites
Barba-negra 117 Posted April 27, 2018 ok guys I just changed the type of object and it worked, this is beautiful: or, really thank you guys are the maximum Share this post Link to post Share on other sites
HazJ 1289 Posted April 27, 2018 No problem! I'm still wondering what laverdad is... 1 Share this post Link to post Share on other sites
Harzach 2516 Posted April 27, 2018 MY MISTAKE! I'm fighting a bad cold, so I'm kind of loopy. I assumed you were using the 55-gallon barrels, which are "Land_BarrelWater_F," but you are using "Land_WaterBarrel_F," which is the bigger water storage container. Updating Haz's version: _barrels = nearestObjects [player, ["Land_WaterBarrel_F"], 200]; if (count _barrels > 0) then { { _pos = getPos _x; _mrk = createMarker [format ["barrel%1Mkr", (_forEachIndex + 1)], _pos]; // so it starts from barrel1Mkr and not barrel0Mkr _mrk setMarkerShape "ICON"; _mrk setMarkerType "hd_dot"; } forEach _barrels; } else { hintSilent "No nearby barrels found"; }; Haz has provided a nice naming convention for the markers, so they will be easier to remove when necessary. 1 Share this post Link to post Share on other sites
Barba-negra 117 Posted April 27, 2018 scripts of beautiful that Share this post Link to post Share on other sites
Barba-negra 117 Posted April 27, 2018 the barrel is just an example guys, it is to detect a torpedo, but I have learned that the names are only variables that do not affect the scripts, it is bit of programming, thanks guys 1 Share this post Link to post Share on other sites
Barba-negra 117 Posted April 27, 2018 _barrels = nearestObjects [player, ["Land_WaterBarrel_F"], 200]; { _name = "Marker" + str (random 10000); _pos = position _x; _mrk = createMarker [_name, _pos]; _mrk setMarkerShape "ICON"; _mrk setMarkerType "hd_dot"; } forEach _barrels; sleep 10; deleteMarker "Marker"; guys add a line to erase the marker after a certain time but it is not deleted, should we add something more? Share this post Link to post Share on other sites
Barba-negra 117 Posted April 27, 2018 what I need to achieve is that the marker follows the object when it moves, I thought about repeating the call of the scripts every so often but it is necessary that the marker be deleted, when the other appears with the new position of the object Share this post Link to post Share on other sites
Harzach 2516 Posted April 27, 2018 The name(s) of the marker(s) created by that code is/are actually "Marker#####," or "Marker" appended with a random number between 0 and 10000: _name = "Marker" + str (random 10000); Again, let's use Haz's better naming system: _barrelMarkers = []; _barrels = nearestObjects [player, ["Land_WaterBarrel_F"], 200]; if (count _barrels > 0) then { { _pos = getPos _x; _name = format ["barrel%1Mkr", (_forEachIndex + 1)]; _mrk = createMarker [_name, _pos]; _mrk setMarkerShape "ICON"; _mrk setMarkerType "hd_dot"; _barrelMarkers pushback _name; } forEach _barrels; sleep 10; {deleteMarker _x} forEach _barrelMarkers; } else { hintSilent "No nearby barrels found"; }; 1 Share this post Link to post Share on other sites
Harzach 2516 Posted April 27, 2018 "Attaching" the markers to moving objects is another step up. 1 Share this post Link to post Share on other sites
Barba-negra 117 Posted April 27, 2018 thanks Harzach, if Attaching, it would also serve Share this post Link to post Share on other sites