Jump to content
Sign in to follow this  
halex1316

Creating cases for an AddAction Hint

Recommended Posts

So basically what I'm working with at the moment, is an interactive mission with quite a few addactions. However, for each one, I need to create its own "addaction.sqf" file and link the action to that script. Is there a way to have ONE script hold all of the hints, and somewhere in the unit's init line addaction ["text","file.sqf"] where I can point to a case that will determine which chunk of text it needs?

Thanks

Share this post


Link to post
Share on other sites

You could have your one file.sqf that each addAction uses, then pass a variable through to that script, then do a switch on that variable:

//example addAction lines
this addAction ["Action 1", "file.sqf", [0]];
this addAction ["Action 2", "file.sqf", [1]];
this addAction ["Action 3", "file.sqf", [2]];
this addAction ["Action 4", "file.sqf", [3]];

//file.sqf

_var = (_this select 3) select 0;

switch (_var) do {

case 0: { hint "Zero Case"; };
case 1: { hint "First Case"; };
case 2: { hint "Second Case"; };
default { hint "Default Case"; };


};

Edited by JShock

Share this post


Link to post
Share on other sites

FYI, you don't have to call a script-file from your addAction, you can also put the code directly into the action.

In some cases you can also combine serval addAction in one by including some conditions and renaming the action depending on the situation. For example, instead of using 2 actions for a door ("open" and "close") you'd use only one and rename it depending on the state of the door.

addAction can be very flexible if used right.

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  

×