Jump to content
Sign in to follow this  
jcae2798

Condition of Arrays

Recommended Posts

I'm needing some guidance/help. I'm no expert to when it comes to scripting, but have been working on a mix of scripts that i am putting together for a mission design i hope to release soon.

Anyways,

What i am trying to do is the following:

There is going to be 1 Array with a list of available CARs selected at random. From that selected One, i then want to compare if this one exists in a second array. I'll then be using a If THEN ELSE code.

So example:

_possible = ["CAR1","CAR2","CAR3"];

_EXECLUDE = ["CAR1","CAR2"];

_randomcar = _possible select (floor random count _possible);

If (_randomcar != _EXECLUDE) then

{CODE}

} else {

CODE};

Of course i know there is a few issues with the above example. I also tried:

If (_randomcar != "car1" OR "car2") then

But this didnt work either. So yea i'm stuck. Any help would be appreciated.

Share this post


Link to post
Share on other sites
if !(_randomcar in _EXCLUDE) then {};

Share this post


Link to post
Share on other sites

Wow...LMAO. Thanks JShock, you're awesome ;) Cant believe it was that simple :)

Share this post


Link to post
Share on other sites
You could also do

_possible = _possible - _EXECLUDE

and skip the condition entirely.

Thanks for the tip. Code above worked great. Thanks guys

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
Sign in to follow this  

×