Jump to content
Sign in to follow this  
icebreakr

Attach command to officer only?

Recommended Posts

I have a MP mission where officer (named "co") needs to have certain actions available such as:

- Open door1/Close door1

- Open door2/Close door2

- Activate smoke

- Spawn jeep

- Spawn truck

All actions need to be available at all times, so repeatable.

"Doors" work via setdamage 1 and setdamage 0.

Smoke is done on preset "invisible heli" locations via createvehicle command.

Spawning of vehicle should work 10m in front of the direction "co" is facing. He can spawn as many vehicle as he likes. Be advised that only "co" character has these actions, not other players in MP session.

Can anyone help?

Share this post


Link to post
Share on other sites

Well you could do it with scripting or in the units init using addAction.

Share this post


Link to post
Share on other sites

Add all of your AddActions to a script, but instead of doing player addAction just do co addAction. Then execute that .sqf file through co's init. So I'm assuming you already have the commands to get all of your actions set up, you just need to know how to piece it together?

Share this post


Link to post
Share on other sites

1. Make a trigger, the condition for which will be "player == co" and the activation for which will be "nul = co execVM 'addactions.sqf'"

2. Make a script called "addActions.sqf" in which you will simply add each action, one after another, using "this" (e.g., "this addAction ['do this','useThisScript.sqf']")

Also, if you want to avoid cluttering up your mission folder with small script files, you can put all of the actions into a single "actions.sqf" file. Then, using a switch statement, you can take an arbitrary argument passed to the script through addAction's optional parameters section (_this select 3) to determine which action to complete.

Share this post


Link to post
Share on other sites

Also if you do not want to use a trigger you can add all of it form the init.sqf

init.sqf

co addAction ["Whatever","doit.sqf",1];
co addAction ["Whatever2","doit2.sqf",1];
etc.

You can also use one script and use the switch statements like ST_Dux said from these: (the # at the end is passed along to the script)(Change it to what ever you need)

then in actions.sqf you will need

_var = _this select 3;

and now _var is what ever number you assigned it in your addaction's.

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  

×