Jump to content
Sign in to follow this  
Enricksolt

Check if a vehicle is empty

Recommended Posts

I have to make a condition that check if the target vehicle is empty or not. Can someone help me?

Thanks You.

Share this post


Link to post
Share on other sites

the above is what code i also use to check if a vehicle is empty, but it really only return true when 0 units inside the vehicle is alive.

so if you dont mind corpses, use that, or if you need to make sure that it really is EMPTY, then use this:

(count (crew vehiclenamehere)) == 0

that will only return true when a vehicle is empty of all dead and alive units.

Share this post


Link to post
Share on other sites

Simple i'm trying do to that when the vehicle is empty an action comes up:

Condition

(count (crew truck1)) == 0

On Activation

truck1 addAction ["setup", "setup_script.sqf"];

And if there is someone inside the action become unavailable

Condition

(count (crew truck1)) >= 1

On Activation

truck1 removeAction 0

The problem is, everytime i create a new "setup" action the ID of the action change, so the removeAction trigger become useless. Can you help me?

Share this post


Link to post
Share on other sites

You could just give the action a handle and then delete it by that name.

on act

act1 = Truck1 addAction ["setup", "setup_script.sqf"];

on act

truck1 removeAction act1

Share this post


Link to post
Share on other sites

Better solution:

Execute once (ex: init field):

Truck1 addAction ["Setup","setup_script.sqf",[],6,false,true,"","count (crew Truck1) < 1"]

Share this post


Link to post
Share on other sites

Big Dawg KS example is the by far better soultion, i works like this: action i always there, but action will only show when vehicle is empty, and the action will only be added once.

i would do a small change though, since you add your action to the truck itself:

Truck1 addAction ["Setup","setup_script.sqf",[],6,false,true,"","count (crew [b]_target[/b]) < 1"];

notice i replaced truck in the last condition with _target.

it works the exact same way, but now you dont need to add in the truck name in the condition as its dynamically handled.

more info on addaction here:

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  

×