Jump to content
Freghar

Make map markers immutable

Recommended Posts

Hello,

is there any way to override the "delete" functionality for player-placed map markers? If not, is there any way to transform player-placed markers to some "global" markers (editor or curator placed) that can't be deleted (though still local, on one client)?

I'm trying to make a "guerilla" mission and magical map synchronization over distance is kind of a problem - I can get range-limited marker placement by removing all channels except Direct Communication, but players can still communicate by removing markers (which is synchronized over any distance/channel).

Thanks for any tips.

Share this post


Link to post
Share on other sites

allMapMarkers

 

At a quick glance that looks like it'll return player created markers. So unless there's a better way, you could run that on a loop and assess the result for any player markers, then delete it and create a new marker with the same setup (colour/type/text etc). Though I can't say for sure the new markers can't be deleted as I've never tried it before or seen it mentioned.

Share this post


Link to post
Share on other sites

No need to loop it just add some event handlers to the map.

 

initPlayerLocal.sqf 

h = [] spawn {
	disableSerialization;

	//Wait for mission display
	waitUntil { !isNull findDisplay 46 };

	//Get the map
	_display = uiNamespace getVariable "RscDiary";
	_map = _display displayCtrl 51;

	//Add DblClick event
	_map ctrlAddEventHandler [ "MouseButtonDblClick", {

		_nul = [] spawn {
			disableSerialization;
			private [ "_classes", "_displays", "_display" ];

			//Make sure insert dialog has loaded
			waitUntil {
				_classes = uiNamespace getVariable "gui_classes";
				_displays = uiNamespace getVariable "gui_displays";
				_index = _classes find "RscDisplayInsertMarker";
				if ( _index > -1 ) then {
					_display = _displays select _index;
					!isNull _display
				}else{
					false
				};
			};

			systemChat "Placing Marker";

			//Add event to inser marker OK button
			_OK = _display displayCtrl 1;
			_OK ctrlAddEventHandler [ "ButtonClick", {

				_nul = [] spawn {

					//Wait for marker to be created
					waitUntil { ( { _x select [ 0, 13 ] == "_USER_DEFINED" }count allMapMarkers ) > 0 };

					systemChat "updating markers";

					//Find marker and replace it
					{
						if ( _x select [ 0, 13 ] == "_USER_DEFINED" ) then {

							systemChat format[ "replacing marker - %1", _x ];

							//Delete User marker
							_pos = getMarkerPos _x;
							_color = getMarkerColor _x;
							_icon = getMarkerType _x;
							_text = markerText _x;
							deleteMarker _x;

							//Replace with local marker
							_numLocalMarkers = { _x select [ 0, 6 ] == "_local" }count allMapMarkers;
							_mrk = createMarkerLocal [ format[ "_local_%1", _numLocalMarkers ], _pos ];
							_mrk setMarkerTypeLocal _icon;
							_mrk setMarkerColorLocal _color;
							_mrk setMarkerTextLocal _text;

						};
					}forEach allMapMarkers;
				};
			}];

		};
	}];
};
 

Or something like this

  • Like 1

Share this post


Link to post
Share on other sites

Any marker that starts with _USER_DEFINED can be removed by any user, so one way of making it permanent is to remove and replace it with non _USER_DEFINED name. Alternatively you can disable use of delete button:
 

findDisplay 12 displayAddEventHandler ["KeyDown", {_this select 1 == 211}];
  • Like 2

Share this post


Link to post
Share on other sites

Thanks for the replies, I thought about overriding the UI element, but that would be incompatible with some mods that simply override the UI, without additional syncing logic (ie. ACE3).

I could definitely make a background loop what would sleep a lot and be virtually nonexistent performance-wise, to re-add the markers without _USER_DEFINED - again, my use case is not to prevent all deletions, just ones that would allow players to easily communicate over distance and if marker creation is limited to short range, some 1-5secs of enabled deletion for the marker is no big deal.

However in the end, I might take the easy way out and just disable the delete button as it (IIRC) cannot be rebound and most mods don't touch it on the map screen (display 12).

Thank you.

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

×