Andy16823 1 Posted February 10, 2022 Hello :) i work currently on a mission. My goal is to let a player open the map and set a waypoint for a helicopter transport. Is there a function which returns the marked waypoint from the map ? Share this post Link to post Share on other sites
Erwin23p 34 Posted February 10, 2022 Hi, you can use onMapSingleClick: e.g. : openMap true; hint "Select on the map the designated position"; onMapSingleClick { //Inside here code to execute when clicked on the map heloWaypoint = createMarker ["LandingPosition", _pos]; heloWaypoint setMarkerShape "ICON"; heloWaypoint setMarkerType "hd_pickup"; "LandingPosition" setMarkerPos _pos; onMapSingleClick ""; }; This script above will open the map, and when you click on the map it will create a "LandingPosition" marker where you clicked. Share this post Link to post Share on other sites
thy_ 164 Posted February 10, 2022 3 hours ago, Andy16823 said: Hello 🙂 i work currently on a mission. My goal is to let a player open the map and set a waypoint for a helicopter transport. Is there a function which returns the marked waypoint from the map ? This little mod provide the same in a super simple way: https://steamcommunity.com/sharedfiles/filedetails/?id=1850026051 Take a look. Share this post Link to post Share on other sites
Andy16823 1 Posted February 10, 2022 Hi 🙂 thanks for the anwers. I used following now but the vehicle isnt moving at all. private _tObject = _this select 0; _tObject addAction["Transport to", { _params = _this select 3; _unit = _params select 0; _pilot = driver _unit; openMap true; hint "Select on the map the designated position"; onMapSingleClick { heloWaypoint = createMarker ["LandingPosition", _pos]; heloWaypoint setMarkerShape "ICON"; heloWaypoint setMarkerType "hd_pickup"; "LandingPosition" setMarkerPos _pos; onMapSingleClick ""; openMap false; _pilot doMove (getMarkerPos heloWaypoint); }; }, [_tObject]]; Share this post Link to post Share on other sites
Erwin23p 34 Posted February 10, 2022 (edited) I'm not sure, but I think getMarkerPos requires the name of the marker, not the marker itself so in this case "LandingPosition". Syntax: getMarkerPos markerName Parameters: markerName: String EDIT: You could simplify your script by skipping all the marker stuff if you don't need it by using directly the parameter "_pos" from "onMapSingleClick". onMapSingleClick { _pilot doMove _pos; openMap false; onMapSingleClick ""; //This line concludes this command code }; And by the way, when you use a function, a command or something new try to read the community wiki about it, it gives you useful info like for example that the line onMapSingleClick "" concludes the code inside this brackets, so this line should be the last inside this command code. Edited February 10, 2022 by Erwin23p Answered too quick, fixed my mistakes Share this post Link to post Share on other sites
Andy16823 1 Posted February 10, 2022 well i changed it but nothing happend 🙂 Share this post Link to post Share on other sites
Erwin23p 34 Posted February 10, 2022 Did you try the edited code above? Share this post Link to post Share on other sites
Harzach 2517 Posted February 10, 2022 private _tObject = _this select 0; _tObject addAction ["Transport to", { params ["_target", "_caller", "_actionId", "_arguments"]; openMap true; hint "Select on the map the designated position"; _target onMapSingleClick { deleteMarker "LandingPosition"; _heloWaypoint = createMarker ["LandingPosition", _pos]; _heloWaypoint setMarkerShape "ICON"; _heloWaypoint setMarkerType "hd_pickup"; _this doMove _pos; openMap false; onMapSingleClick ""; hintSilent ""; }; }]; 1 Share this post Link to post Share on other sites
opusfmspol 282 Posted February 10, 2022 I would suggest: 1) End the onMapSingleClick code with true or false, to tell the engine whether to include default engine handling. An example of default handling is, when player is the commander of a vehicle, clicking on map tells the driver where to move. Would you want that sort of engine click behavior included with the map click? - Ending onMapSingleClick with true tells the engine the code completes the click action, do not include the default engine handling. - Ending onMapSingleClick with false tells the engine the code does not complete the click action, also include the default engine handling. 2) Only use onMapSingleClick to get the pos. After that, have the addAction code do the work, but also handle interruption, i.e. the player chooses to close the map without selecting a position. At the end of addAction, clear the map click (onMapSingleClick ""). A very basic example: openMap true; hint "information"; PosClicked = false; _target onMapSingleClick {ClickPosition = _pos; PosClicked = true; true}; WaitUntil {Sleep 0.1; (PosClicked || !visibleMap}; PosClicked = false; if (visibleMap) then { // do the marker and waypoint stuff openMap false; }; onMapSingleClick ""; hintSilent ""; 2 Share this post Link to post Share on other sites
Andy16823 1 Posted February 11, 2022 Thanks for all the help got it done. You will find the script bellow in case some else needs something like this as well. private _tObject = _this select 0; _tObject addAction["Transport to", { params ["_target", "_caller", "_actionId", "_arguments"]; // Save starting vector _oldPos = position _target; openMap true; hint "Select on the map the designated position"; // Set landing zone! _target onMapSingleClick { deleteMarker "LandingPosition"; _heloWaypoint = createMarker ["LandingPosition", _pos]; _heloWaypoint setMarkerShape "ICON"; _heloWaypoint setMarkerType "hd_pickup"; _this doMove getMarkerPos "LandingPosition"; openMap false; onMapSingleClick ""; hintSilent ""; }; // Wait until the helicopter reachs the landing point. If he reachs the point he stops and land waitUntil { _cPos = position _target; _meters = _cPos distance2D getMarkerPos "LandingPosition"; if (_meters < 100) then { hint "landing soon!"; true; } else { hint str _meters; false; }; }; doStop _target; _target land "GET OUT"; // Wait until the helicopter landed waitUntil { isTouchingGround _target; }; hint "Helicopter is landet!"; // Wait 30 seconds and fly back to base _sec = 0; waitUntil { sleep 1; _sec = _sec + 1; if(_sec >= 30) then{ true; } else { false; } }; _this doMove _oldPos; hint "Helicopter is flying back!"; // Wait until the heli reachs his starting position and land waitUntil { _cPos = position _target; _meters = _cPos distance2D _oldPos; if (_meters < 100) then { true; } else { hint str _meters; false; }; }; doStop _target; _target land "GET OUT"; // wait until he is touching the ground and shut down the engine waitUntil { isTouchingGround _target; }; _target engineOn false; }, [_tObject]]; and it get called inside the editor with this function [this, airport_military_transport_pilot_1] execVM "scripts\transport.sqf"; 1 Share this post Link to post Share on other sites
Harzach 2517 Posted February 11, 2022 _this doMove getMarkerPos "LandingPosition"; This is sort of redundant while still inside the onMapSingleClick, which is why I wrote it as _this doMove _pos; 1 Share this post Link to post Share on other sites
Magpie75 0 Posted May 1, 2022 could someone please explain where to put this script Share this post Link to post Share on other sites