Nag's FoV 0 Posted May 26, 2017 Hello,I want to trigger when the player insert a marker on his map in a specific area, like in the prologue mission, where you have to find AAF position (youtube link : ).If you have any link or answer which can help me, please post it!Thanks. Share this post Link to post Share on other sites
pierremgi 4743 Posted May 26, 2017 Not easy because there is no object created (not like triggers). So, you have to detect a change in the allMapMarkers and sort them with their string USER_DEFINED... Here is an example I wrote to place a task when a player uses some types of markers. Just modify the code to do what you need instead of creating a task. Share this post Link to post Share on other sites
Nag's FoV 0 Posted May 26, 2017 Thank you! Im not used at scripting, but this gonna help me a lot! Maybe you can help me again; where can i define the area where the marker must be? Thanks. Share this post Link to post Share on other sites
pierremgi 4743 Posted May 26, 2017 In the script, the marker _mk is the one the player just placed. I guess you have a trigger with an area somewhere. Name it (mytrigger for example). Then in the script you can check on a condition: if (_mk inArea mytTrigger) then {....}; NB: That works also with another marker ellipse or rectangle type. No need to be a trigger. 1 Share this post Link to post Share on other sites
Midnighters 152 Posted May 26, 2017 1 minute ago, pierremgi said: In the script, the marker _mk is the one the player just placed. I guess you have a trigger with an area somewhere. Name it (mytrigger for example). Then in the script you can check on a condition: if (_mk inArea mytTrigger) then {....}; yeah, I've used something similar like this in a script before. For detecting how close a user placed marker is near a town, pretty simple Share this post Link to post Share on other sites
Nag's FoV 0 Posted May 30, 2017 On 26/05/2017 at 6:48 PM, pierremgi said: In the script, the marker _mk is the one the player just placed. I guess you have a trigger with an area somewhere. Name it (mytrigger for example). Then in the script you can check on a condition: if (_mk inArea mytTrigger) then {....}; NB: That works also with another marker ellipse or rectangle type. No need to be a trigger. How sould I define mytTrigger? I have an error : Undefined variable in expression: mytTrigger. I search on the forums but don't figured out how to define my trigger/area in the script. Thank you for your previous messages. Share this post Link to post Share on other sites
pierremgi 4743 Posted May 30, 2017 If you placed a trigger on map, just name it (say myTrigger or what ever you want), then check if the marker I named _mk in the script is inArea of this variable name like this: _MGI_taskOnMarker = addMissionEventHandler ["map",{ if (_this select 0) then { [] spawn { _mks = allMapMarkers; private ["_tgt","_tgtText","_mk"]; while {visibleMap && hasInterface} do { waitUntil {!(_mks isEqualTo allMapMarkers)}; if (count allMapMarkers > 0) then { _mk = allMapMarkers select (count allMapMarkers - 1); if (_mk inArea myTrigger) then { < do what you want > }; }; _mks = allMapMarkers; }; }; }; }]; Share this post Link to post Share on other sites
Larrow 2803 Posted May 30, 2017 Why not just use a double click eventhandler on the map control, wait for the insert marker dialog to popup then add a unload event to it. The double click will give you the position that was clicked and the unload will give you the exitcode which will tell you whether a marker was placed. TAG_fnc_createSelectionMarker = { _position = player getPos [ random 500, random 360 ]; if !( getMarkerPos "border" isEqualTo [ 0, 0, 0 ] ) then { deleteMarker "border"; }; _mrk = createMarker [ "border", _position ]; _mrk setMarkerShape "ELLIPSE"; _radius = 50 + floor random 100; _mrk setMarkerSize [ _radius, _radius ]; _mrk setMarkerBrush "Border"; _mrk setMarkerColor "ColorBlue"; }; TAG_fnc_waitForPlayerInput = { waitUntil{ !isNull findDisplay 12 }; findDisplay 12 displayCtrl 51 ctrlAddEventHandler [ "MouseButtonDblClick", { params[ "_mapCtrl", "_button", "_mouseX", "_mouseY" ]; if ( _button isEqualTo 0 ) then { player setVariable[ "insertPos", _mapCtrl ctrlMapScreenToWorld[ _mouseX, _mouseY ] ]; _nul = [] spawn { waitUntil{ !isNull findDisplay 54 }; _nul = findDisplay 54 displayAddEventHandler [ "Unload", { _exitCode = param[ 1 ]; if ( _exitCode isEqualTo 1 ) then { if ( ( player getVariable "insertPos" ) inArea "border" ) then { hint "You placed a marker inside the Area"; }else{ hint "You placed a marker outside the Area"; }; }; }]; }; }; }]; }; openMap true; hint "Place a marker either inside or outside the area shown"; _nul = [] call TAG_fnc_createSelectionMarker; _nul = [] spawn TAG_fnc_waitForPlayerInput; Just run the above in the debug console whilst previewing a mission. Commented code.. Spoiler //Function to place a marker for the player to click in/out TAG_fnc_createSelectionMarker = { _position = player getPos [ random 500, random 360 ]; if !( getMarkerPos "border" isEqualTo [ 0, 0, 0 ] ) then { deleteMarker "border"; }; _mrk = createMarker [ "border", _position ]; _mrk setMarkerShape "ELLIPSE"; _radius = 50 + floor random 100; _mrk setMarkerSize [ _radius, _radius ]; _mrk setMarkerBrush "Border"; _mrk setMarkerColor "ColorBlue"; }; TAG_fnc_waitForPlayerInput = { //Wait for the map to open waitUntil{ !isNull findDisplay 12 }; //add Dbl click event to map findDisplay 12 displayCtrl 51 ctrlAddEventHandler [ "MouseButtonDblClick", { params[ "_mapCtrl", "_button", "_mouseX", "_mouseY" ]; //if the mouse button was the left one if ( _button isEqualTo 0 ) then { //Save clicked world position in player variable player setVariable[ "insertPos", _mapCtrl ctrlMapScreenToWorld[ _mouseX, _mouseY ] ]; //Create a new thread so we can wait again _nul = [] spawn { //Wait for insert marker popup waitUntil{ !isNull findDisplay 54 }; //Add UnLoad event to it _nul = findDisplay 54 displayAddEventHandler [ "Unload", { //Get the exit code _exitCode = param[ 1 ]; //1 = ok, 2 = cancel or Escape was pressed if ( _exitCode isEqualTo 1 ) then { //Did we place a marker in the border marker if ( ( player getVariable "insertPos" ) inArea "border" ) then { hint "You placed a marker inside the Area"; }else{ hint "You placed a marker outside the Area"; }; }; }]; }; }; }]; }; openMap true; hint "Place a marker either inside or outside the area shown"; _nul = [] call TAG_fnc_createSelectionMarker; _nul = [] spawn TAG_fnc_waitForPlayerInput; 1 Share this post Link to post Share on other sites
Nag's FoV 0 Posted June 1, 2017 On 30/05/2017 at 5:20 PM, pierremgi said: If you placed a trigger on map, just name it (say myTrigger or what ever you want), then check if the marker I named _mk in the script is inArea of this variable name like this: _MGI_taskOnMarker = addMissionEventHandler ["map",{ if (_this select 0) then { [] spawn { _mks = allMapMarkers; private ["_tgt","_tgtText","_mk"]; while {visibleMap && hasInterface} do { waitUntil {!(_mks isEqualTo allMapMarkers)}; if (count allMapMarkers > 0) then { _mk = allMapMarkers select (count allMapMarkers - 1); if (_mk inArea myTrigger) then { < do what you want > }; }; _mks = allMapMarkers; }; }; }; }]; Pierre: Yeah that's exactly what i done, as you told me to do, but the script doesn't recognize the area or the trigger variable name, I don't know why. So i tried what Larrow posted, and finally succeeded! Pierre's way was easier to edit the zone but this isn't a big deal. Thanks to both of you! Share this post Link to post Share on other sites