Jump to content
Djavu

using FindIf and DeleteAt

Recommended Posts

Hello people. I have a doubt, but it's just for study.
using the deleteAt and findIf commands:
for example: I have an array that stores units close to the player

arr = nearestObjects [player, ["Man"],100]; 

to delete the dead units i would use:

_arr deleteAt (_arr findIf {not alive _x});

Problem solved.
But what if I want to save the position of the dead unit in the array, to indicate the number ex:

_dead = _arr findIf {not alive _x};

How could I use  _dead  on  deleteAt? being an array, not a number?
Not for use in this example, but for use on another occasion.
As I said at the beginning, it's for studies only, I'm trying to learn a little about Sqf. Thanks

Share this post


Link to post
Share on other sites

Read the BIKI for commands. Watch for arguments and return data (if any).

_arr deleteAt (_arr findIf {not alive _x});

will not delete all the dead units at once.

For your aim, it's easier to:
_deadUnits = _arr select {!alive _x};
_deadPos = _deadUnits apply {getPos _x};

 

  • Thanks 1

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

×