Jump to content
Sign in to follow this  
Craig_VG

Triggers and the timeout option.

Recommended Posts

Hey everyone I have a quick question. Because I am new to scripting. :j: :confused:

I am making a mission and in that mission I want a timer to start when the player enters a trigger, and when the player exits I want it to stop counting down, and then repeat if the player enters again. Is there a script to do this, or is it just possible in the trigger menu?

Thanks!

Share this post


Link to post
Share on other sites

The Timeout feature of a trigger is a counter, but not a public one and it won't keep it's state. It just means the trigger's condition needs to have been true for that long before it activates.

The Countdown feature means after that much time has passed the trigger will activate it. Again, it won't keep track of it's number once you leave the trigger.

Here's one way of doing a persistent countdown:

init.sqf:

counter = 10;
counting = false;

while {counter > 0} do {
hintSilent format["%1", counter];
};

Trigger:

Anybody - Present - Repeatedly

Condition =

player in this list

onAct =

counting = true; nul = [] execVM "counting.sqf";

onDea =

counting = false;

counting.sqf =

while {counting && counter > 0} do {
counter = counter - 1;
sleep 1;
};

Maybe have a 2nd trigger checking for counter == 0 and have that hint "Times Up" or something.

Edited by kylania

Share this post


Link to post
Share on other sites

That works! Thanks!

Another thing, is it possible to use this for multiple triggers with separate counters for each?

After each counter stops I want the script to delete a trigger.

Once again thanks!

EDIT: never mind, I figured it out on my own. :)

Edited by bobtom

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  

×