Thorimus 2 Posted August 26, 2018 I'm trying to make a script which spawns a vehicle on a player-placed marker. The following code: _vic1 = createVehicle ["C_Offroad_01_F",getMarkerPos "VehicleHere",[],0,"NONE"]; does not work, presumably because markerText and markerName are not the same. getMarkerPos works by finding the position of a marker with that specific **name**, not text, and so is useless for determining the position of markers by text, which is what I need. There is no documentation on this (prove me wrong, i beg you) and many hours were wasted trying to get this to work. I need a script which gets me the position of a marker with specific text, for example "Vehicle Here". This is beyond my coding ability and it would be a great help if one of you wizards could help me. E: Courtesy of Schatten, this is the solution: _marker = ""; {if ((markerText _x) == "MARKERTEXT") exitWith {_marker = _x;};} forEach allMapMarkers; if (_marker != "") then { vic1 = createVehicle ["VEHICLE CLASSNAME", getMarkerPos _marker, [], 0, "NONE"];}; Share this post Link to post Share on other sites
Schatten 290 Posted August 26, 2018 @Thorimus, _marker = ""; {if ((markerText _x) == "Vehicle Here") exitWith {_marker = _x;};} forEach allMapMarkers; Share this post Link to post Share on other sites
Thorimus 2 Posted August 26, 2018 1 minute ago, Schatten said: @Thorimus, _marker = ""; {if ((markerText _x) == "Vehicle Here") exitWith {_marker = _x;};} forEach allMapMarkers; How do I use this with the createVehicle command? Share this post Link to post Share on other sites
Schatten 290 Posted August 26, 2018 @Thorimus, _marker = ""; {if ((markerText _x) == "Vehicle Here") exitWith {_marker = _x;};} forEach allMapMarkers; if (_marker != "") then { _vic1 = createVehicle ["C_Offroad_01_F", getMarkerPos _marker, [], 0, "NONE"]; }; Share this post Link to post Share on other sites
Thorimus 2 Posted August 26, 2018 9 minutes ago, Schatten said: @Thorimus, _marker = ""; {if ((markerText _x) == "Vehicle Here") exitWith {_marker = _x;};} forEach allMapMarkers; if (_marker != "") then { _vic1 = createVehicle ["C_Offroad_01_F", getMarkerPos _marker, [], 0, "NONE"]; }; Thank you so much, this spawns the vehicle. However, when I refer to "_vic1" in another piece on script, in gives me an "undefined variable in expression" error for it. I removed the underscores and now it works. TIL underscores make it so that the variable only works in that scope/script Share this post Link to post Share on other sites
Schatten 290 Posted August 26, 2018 @Thorimus, sure, _vic1 is defined only in if-statement scope. For _vic1 to be defined outside, just place _vic1 = objNull; after _marker = ""; But don't forget check if _vic1 is null! 1 Share this post Link to post Share on other sites
Schatten 290 Posted August 26, 2018 7 minutes ago, Thorimus said: However, when I refer to "_vic1" in another piece on script, in gives me an "undefined variable in expression" error for it. I removed the underscores and now it works. TIL underscores make it so that the variable only works in that scope/script https://community.bistudio.com/wiki/Variables#Scopes Share this post Link to post Share on other sites
stanhope 411 Posted August 26, 2018 private _marker = ""; {if ((toLower(markerText _x)) == "vls strike here") exitWith {_marker = _x;};} forEach allMapMarkers; if (_marker == "") exitWith {}; private _trgt = createVehicle ["C_Offroad_01_F", getMarkerPos _marker, [], 0, "CAN_COLLIDE"]; west reportRemoteTarget [_trgt, 3600]; _trgt confirmSensorTarget [west, true]; VLS fireAtTarget [_trgt, "weapon_vls_01"]; Untested Share this post Link to post Share on other sites