Jump to content
Sign in to follow this  
Tand3rsson

Script going off only once?

Recommended Posts

Hi!

I have made a very simple script, for a body guard mission I am makeing. When a man1 fires a FN_FAL, body1 gets an addaction "Annie, Follow!", (which causes the VIP, Annie Baker to join his squad) and ability to call in a chopper and some other stuff.

1. However, how do I go about makeing the script fire only once? :-S Now, everytime man1 fires his weapon, body1 gets a new action.

Here is my script (dont laugh):

[["Transport"], body1] call BIS_SOM_addSupportRequestFunc; som1 setVariable ["TSS_vehicle_custom", heli1];

dig = body1 addAction ["Annie, Follow!","join.sqf"];

body1 groupChat "SHOTS FIRED! SHOTS FIRED!";

2. Also, the last part, where the bodyguard1, yells the text dosent work either... :S

My script knowledge is very limited, and most is some type of copy/paste solution...

---------- Post added at 02:06 PM ---------- Previous post was at 02:01 PM ----------

OK, I kind of got smart a minute after the last post, and did this

[["Transport"], body1] call BIS_SOM_addSupportRequestFunc; som1 setVariable ["TSS_vehicle_custom", heli1];

body1 removeAction dig;
sleep 0.1;
dig = body1 addAction ["Annie, Follow!","join.sqf"];

body1 groupChat "SHOTS FIRED! SHOTS FIRED!";

That works, almost as I want it to. However, the second problem, with groupChat remains :S

Share this post


Link to post
Share on other sites

Hi,

If I'm not mistaken I believe this code at the end of it what will end the script:

if(true)exitWith{};

};

Share this post


Link to post
Share on other sites

Sorry but: if(true)exitWith{}; is useless whatsoever.

You can make a variable to check if you already added the action:

[["Transport"], body1] call BIS_SOM_addSupportRequestFunc; som1 setVariable ["TSS_vehicle_custom", heli1];

if ([url="http://community.bistudio.com/wiki/isNil"]isNil[/url] "[color="SeaGreen"]Body1ActionAdded[/color]") then {
dig = body1 addAction ["Annie, Follow!","join.sqf"];

[color="SeaGreen"]Body1ActionAdded = true;[/color]
};

body1 groupChat "SHOTS FIRED! SHOTS FIRED!";

For the groupChat problem... Whats the problem with it? Does it not show up? You can only see groupChat if he is in your group. Use globalChat or sideChat instead.

Share this post


Link to post
Share on other sites

I beg to differ,

I use it for my init scripts to end other scripts running, if I didn't use the code then the scripts wouldn't end.

But the init script is the only place I use it, most of the scripts i have used that have had a init script included used that code,

it may not apply here but it was merely a suggestion.

Share this post


Link to post
Share on other sites
I use it for my init scripts to end other scripts running, if I didn't use the code then the scripts wouldn't end.

This actually isn't true although it's a popular miconception. All scripts will exit when there's no more code left to run.

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  

×