Jump to content
Joe98

How to delete 50 markers with 1 command instead of 50 commands?

Recommended Posts

I placed 50 markers on the map to allow me to start at 50 places at random.

As the mission starts I want to delete the 50 markers.

The markers are named marker0 to marker49.

To delete the first marker the command is: deleteMarker "marker0";

How can I write a command to delete the 50 markers with one command instead of 50 commands?

Share this post


Link to post
Share on other sites

Adapting the example from the Biki:

{
  private "_a";
  _a = toArray _x;
  _a resize 6;
  if (toString _a == "marker") then {
    deleteMarker _x;
  }
} forEach allMapMarkers;

Or just a for 0 to 49 loop deleting them all.

for "_i" from 0 to 49 do {
    deleteMarker format["marker%1", _i];
};
  • Like 4

Share this post


Link to post
Share on other sites

{deleteMarker _x} forEach allMapMarkers; ;)

this deletes every marker on map even those which could be needed.

Share this post


Link to post
Share on other sites
{deleteMarker _x} forEach ["marker0","marker1","markerN"];

 kylania 's way however is the best solution for your problem.

Share this post


Link to post
Share on other sites

There are invisible markers you can use too. Forget the name, but it's the purple ring ones.

You can also just set the alpha channel to 0 as well as an option if you need to keep them.

Share this post


Link to post
Share on other sites

Function delete all markers with names starting from given template:

Fn_DeleteMarkersStartingWith = {
	{
	 	if (_x find _this == 0) then {
			deleteMarker _x}
	} forEach allMapMarkers
};

For example:

// Removes markers "MySuperMarker_123", "MySuperMarker_A", "MySuperMarker_SomethingElse"
"MySuperMarker_" call Fn_DeleteMarkersStartingWith;
  • Like 1

Share this post


Link to post
Share on other sites

Neat way to check that using the new syntax for find, serena!  

 

Note that find is case sensitive.

Share this post


Link to post
Share on other sites

Thanks for the responses.

 

It turns out that the invisible marker is the best solution!

 

My plan was to be able to see the marker in the editor but not be able to see the markers in-game.

 

The correct name is:   Markers-System-Empty

 

.

  • Like 1

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

×