Jump to content
Twiznak

[Solved] Check if player is inArea of markers, from an array of markers.

Recommended Posts

Hello everyone! I need help with a condition checking if a players position is inArea of markers, from an array of markers. Here is my code:

myMarkers = ["marker_0","marker_1"];

if !(player inArea myMarkers) then { hint "Get back line soldier!"; };

I COULD just copy/pasta this control structure _x amount of times for each marker in my array, but that is needlessly redundant. Please help me optimize this code!

Share this post


Link to post
Share on other sites

@Twiznak,

if ((myMarkers findIf { player inArea _x }) < 0) then { hint "Get back line soldier!"; };

 

  • Like 3
  • Thanks 1

Share this post


Link to post
Share on other sites
14 minutes ago, Schatten said:

@Twiznak,


if ((myMarkers findIf { player inArea _x }) < 0) then { hint "Get back line soldier!"; };

 

@Schatten , Thank you! findIf is the correct operator here. Thank you for helping/educating me 🙂 I will read the BIwiki page until I understand the "Why" behind the "How". Again, thank you for your help!

  • Like 1

Share this post


Link to post
Share on other sites

Glad you got a nice answer here (personally I am a big fan of findIf and I have a feeling that it is ALWAYS the right command to use :D:P). Feel free to throw any question you may have if you find yourself stuck with this or any other command.

 

Have fun and ArmA a lot 🙂.

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

×