Jump to content

Recommended Posts

Hello, i want to have 3 markers on the map where i can get an action 40m from it. i can get it to work if i change  (getMarkerPos _markerList) to getMarkerPos 'APF_1' but then only one marker works. it feels really dumb to make 3 actions for the same thing. Do anyone know how to get it to take the names in an array instead? sorry for bad english.

_markerList = ["APF_1","APF_2","APF_3"];

player addaction ["<t color='#ff0066'>Plant</t>","actions\plant.sqf", "", 0, true, true, "", "alive _target AND _target distance (getMarkerPos _markerList) <= 40"];

Share this post


Link to post
Share on other sites

You need to retrieve the position of each element of the array _markerList separately. We do this using forEach.

 

I can't test right now, but it should be something along the lines of

player addaction ["<t color='#ff0066'>Plant</t>","actions\plant.sqf", "", 0, true, true, "", "alive _target AND {_target distance (getMarkerPos _x) <= 40} forEach _markerList"];

 

Share this post


Link to post
Share on other sites
On 3/10/2020 at 2:29 AM, Harzach said:

You need to retrieve the position of each element of the array _markerList separately. We do this using forEach.

 

I can't test right now, but it should be something along the lines of


player addaction ["<t color='#ff0066'>Plant</t>","actions\plant.sqf", "", 0, true, true, "", "alive _target AND {_target distance (getMarkerPos _x) <= 40} forEach _markerList"];

 

Unfortunately that's only gonna return the comparison of the last marker in the list. Also _markerList is not defined in the condition scope. 

 

Instead use findIf for the condition:

"alive _target And TAG_markerList findIf  {_target distance2D getMarkerPos _x <= 40}  >= 0"

 

and make the list global:

TAG_markerList = ["APF_1","APF_2","APF_3"];

  • Like 1

Share this post


Link to post
Share on other sites

You can also use the 4th parameter for the scripr of action. (params ["_target", "_caller", "_actionId", "_arguments"];)

Share this post


Link to post
Share on other sites
2 hours ago, mrcurry said:

Unfortunately that's only gonna return the comparison of the last marker in the list. Also _markerList is not defined in the condition scope.

Thanks! I had a feeling something wasn't right. As usual, I probably should have stepped away from the keyboard...

Share this post


Link to post
Share on other sites
1 hour ago, pierremgi said:

You can also use the 4th parameter for the scripr of action. (params ["_target", "_caller", "_actionId", "_arguments"];)

Supplied arguments are not available in the condition though.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×