Metis-Team / mts_marker

NATO joint military symbols for ArmA 3
Other
17 stars 8 forks source link

Add marker created server event / log function #98

Open DeliciousJaffa opened 1 month ago

DeliciousJaffa commented 1 month ago

Is your feature request related to a problem? Please describe. As you cannot hover over and see who created a METIS Marker, It would be useful to be able to retroactively find who created what markers.

Describe the solution you'd like A CBA server event emitted by clients when a marker is created, with ideally a built in logging function that could be enabled by CBA settings.

Describe alternatives you've considered Looping over the metis map markers - would have to determine when edited, which are new, etc

Additional context N/A

Timi007 commented 1 month ago

You should be able to do this with the MarkerCreated eventhandler as well as mts_markers_fnc_isMtsMarker and mts_markers_fnc_getPlayerUID.

Something like this (not tested it):

seen_mts_markers = [];
addMissionEventHandler ["MarkerCreated", {
    params ["_marker", "_channelNumber", "_owner", "_local"];

    if (([_marker] call mts_markers_fnc_isMtsMarker) isNotEqualTo 1) exitWith {};

    private _namePrefix = (_marker splitString "_") select 0;

    // When a mts marker is created, multiple vanilla markers are created,
    // we only want to handle the event once.
    if (_namePrefix in seen_mts_markers) exitWith {};
    seen_mts_markers pushBack _namePrefix;

    // Maybe _owner is useful here? Or:
    private _playerUID = [_namePrefix] call mts_markers_fnc_getPlayerUID;
    private _unit = _playerUID call BIS_fnc_getUnitByUID;
}];

But yeah, I think CBA events would be convenient in the future.

I don't understand what you mean by "built in logging function"? What should be logged? Where should it be logged to?