Jump to content

Help with custom Map Markers


Guest

Recommended Posts

Hi, umm in the guy showed on how to do the Client Map Markers with Player Name, so i thought i would be kinda awesome, if you can write the Marker Type in the box, where you write the text and if the type is valid, the marker will be deleted and a new one created with that text. So this is what i came up with (but it's not working, actually it's not even adding the player name?)

 

// =============================================================================
// | GG_MapMarker.sqf [1.0]                                                |
// | Script adds player name to the created map marker                         |
// | by Prodavec, thanks to Gunter Severloh, PvPscene, Maca               |
// =============================================================================

// ====================================
// | INCLUDES                         |
// ====================================

// ====================================
// | DEFINITIONS                      |
// ====================================
//#define     MMT_DEBUG

#define     MMT_DIK_ESC                 1
#define     MMT_DIK_ENTER               28
#define     MMT_DIK_KPENTER             156
#define     MMT_SEARCHTIME              2
#define     MMT_DISPLAY_MAP             12
#define     MMT_DISPLAY_MARKER          54
#define     MMT_CONTROL_MAP             51
#define     MMT_CONTROL_MARKER          101

// ====================================
// | PRE-INIT                         |
// ====================================

// ====================================
// | VARIABLES                        |
// ====================================

// ====================================
// | FUNCTIONS                        |
// ====================================
fnc_marker_keyUp_EH = {
    private ["_needle","_haystack","_needleLen","_hay","_handled", "_display", "_dikCode", "_control", "_text"];
    _display = _this select 0;
    _dikCode = _this select 1;
    _handled = false;
	
    if ((_dikCode == MMT_DIK_ENTER) || (_dikCode == MMT_DIK_KPENTER)) then {
        _control = _display displayCtrl MMT_CONTROL_MARKER;
        _text = ctrlText _control;
        if (_text == "") then {
            _text = format ["%1", name player];
        } else {
            _text = format ["%1: %2", name player, _text];
        };
		
		_needle = ["Empty", "Flag", "Flag1", "Dot", "Destroy", "Start", "End", "Warning", "Join", "Pickup", "Unknown", "Marker", "Arrow", "mil_objective", "mil_marker", "mil_flag", "mil_arrow", "mil_arrow2", "mil_ambush", "mil_destroy", "mil_start", "mil_end", "mil_pickup", "mil_join", "mil_warning", "mil_unknown", "mil_circle", "mil_dot", "mil_box", "mil_triangle", "hd_objective", "hd_flag", "hd_arrow", "hd_ambush", "hd_destroy", "hd_start", "hd_end", "hd_pickup", "hd_join", "hd_warning", "hd_unknown", "hd_dot", "Select", "Faction_US", "Faction_USMC", "Faction_CDF", "Faction_RU", "Faction_INS", "Faction_GUE", "NATO_base", "b_empty", "o_empty", "n_empty", "b_unknown", "o_unknown", "n_unknown", "b_inf", "o_inf", "n_inf", "b_motor_inf", "o_motor_inf", "n_motor_inf", "b_mech_inf", "o_mech_inf", "n_mech_inf", "b_armor", "o_armor", "n_armor", "b_recon", "o_recon", "n_recon", "b_air", "o_air", "n_air", "b_plane", "o_plane", "n_plane", "b_uav", "o_uav", "n_uav", "b_med", "o_med", "n_med", "b_art", "o_art", "n_art", "x_art", "b_mortar", "o_mortar", "n_mortar", "x_mortar", "b_hq", "o_hq", "n_hq", "b_support", "o_support", "n_support", "b_maint", "o_maint", "n_maint", "b_service", "o_service", "n_service", "group_0", "group_1", "group_2", "group_3", "group_4", "group_5", "group_6", "group_7", "group_8", "group_9", "group_10", "group_11", "waypoint", "selector_selectable", "selector_selectedEnemy", "selector_selectedFriendly", "selector_selectedMission", "HQ", "FOB", "Airport", "Heliport", "Artillery", "AntiAir", "City", "Strongpoint", "Depot", "FireMission", "AirTeam", "CommandTeam", "Headquarters", "HeavyTeam", "InfantryTeam", "LightTeam", "Attack", "Move", "Defend", "Vehicle", "DestroyedVehicle", "RepairVehicle", "SalvageVehicle", "SupplyVehicle", "Town", "Camp", "Tank", "Man", "Air", "Car", "Boat"];
		_haystack = toArray _text; 
		_needleLen = count _needle; 
		_hay = +_haystack; 
		
		_hay resize _needleLen; 
		
		for "_i" from _needleLen to count _haystack do { 
			if (toString _hay == _needle) exitWith {setMarkerTypeCustom = [_display,_needle,_text];publicVariable "setMarkerTypeCustom";}; 
			_hay set [_needleLen, _haystack select _i]; 
			_hay set [0, "x"]; _hay = _hay - ["x"] 
		};
		
        _control ctrlSetText _text;
        _display displayRemoveAllEventHandlers "keyUp";
        _display displayRemoveAllEventHandlers "keyDown";
    };

    _handled;
};

fnc_marker_keyDown_EH = {
    private ["_handled", "_display", "_dikCode"];
    _display = _this select 0;
    _dikCode = _this select 1;
    _handled = false;

    if (_dikCode == MMT_DIK_ESC) then {
        _display displayRemoveAllEventHandlers "keyUp";
        _display displayRemoveAllEventHandlers "keyDown";
    };

    _handled;
};

fnc_marker_type_EH = {
    private ["_display", "_needle","_text","_control","_pos","_textToArray","_toString"];
    _display = _this select 0;
    _needle = _this select 1;
	_text = _this select 2;
	
	//Get current Marker
	_control = _display displayCtrl MMT_DISPLAY_MARKER;
	
	//Get Marker Position
	_pos = ctrlPosition _control;
	
	//Delete current Marker
	ctrlDelete _control;
	
	//Remove the needle from the text (?) Test
	_textToArray = toArray _text;
	_textToArray = _textToArray - [_needle];
	_toString = toString _textToArray;
	
	//Set New Marker (We'll use the display, as caller)
	_display  = createMarker [_needle,_pos];
	_display  setmarkerType _needle;
	_display  setMarkerText _toString;
	};
	
	
}; "setMarkerTypeCustom" addPublicVariableEventHandler {(_this select 1) call fnc_marker_type_EH;};

fnc_map_mouseButtonDblClick_EH = {
    private ["_display"];

    disableUserInput true; // Scheduled environment

    (time + MMT_SEARCHTIME) spawn {
        disableSerialization;

        while {time < _this} do {
            _display = findDisplay MMT_DISPLAY_MARKER;
            if !(isNull _display) exitWith {
                _display displayAddEventHandler ["keyUp", "_this call fnc_marker_keyUp_EH"];
                _display displayAddEventHandler ["keyDown", "_this call fnc_marker_keyDown_EH"];
            };
        };
        disableUserInput false;
    };
    true;
};

// ====================================
// | MAIN                             |
// ====================================
waitUntil {sleep 0.1; !isNull (findDisplay MMT_DISPLAY_MAP)};
((findDisplay MMT_DISPLAY_MAP) displayCtrl MMT_CONTROL_MAP) ctrlAddEventHandler ["mouseButtonDblClick", "call fnc_map_mouseButtonDblClick_EH"];

Can anybody find what's wrong?

Link to comment
Share on other sites

I am having trouble understanding the logic, What are you trying to do and whats is the reason behind this. How is this suppose to function?

 

Right, you double click the Map and a Marker appears, also you can type in some Text, that will stand next to the Marker. I guess everybody knows that. So if there's a valid Marker Type, like in the _needle, which contains all marker types from arma2, it will not create the default marker, which is a circle with an X inside, it will create a Marker with the type just wrote in that textbox and ofc the text. So that's how it should work.

In the code part, i will put the text in an array and then search that and see, if any of those Marker Types appear in the text.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...