Jump to content
Sign in to follow this  
colosseum

Question about time limits to reset a trigger

Recommended Posts

All,

I've made a USMC checkpoint on a zombie themed map, and I have a trigger set up so that when a player enters the checkpoint, zombies are spawned around the checkpoint. Unfortunately I can only have this happen once, as the "repeatedly" setting means that if the player unintentionally steps in and out of the trigger box the map can become flooded with zombies.

I'd like to know how to tell the game to wait a few minutes before reactivating the trigger... surely someone here knows how to do this, but everywhere I've looked, I haven't found the answer!

Thanks!

Ian

Share this post


Link to post
Share on other sites

Just run the script again in a few minutes after the first time.

You could name the first trigger that spawns the zombies, something like spawnzombies, then have another trigger setup like the first one to run the same script again, but in this second triggers condition field instead put

TriggerActivated spawnzombies

and in the timer boxes put 120 in each of them

so once the first triggers spawned the zombies, the next trigger will start the countdown and run the script again in 120 seconds.

That's just one very simple basic way of doing it.

Share this post


Link to post
Share on other sites

All you need is a variable that allows the trigger to fire only so often. For example, create a variable called "spawnAllowed" and set it to true at mission start. Now in your trigger, change your condition from "this" to "this && spawnAllowed". When the trigger fires, have the following line of code run along with your spawn script:

spawnAllowed = false;[] spawn {sleep 300;spawnAllowed = true}

This will make it so the trigger can only be fired once every five minutes. You can change the number of seconds to sleep to use whatever interval you'd like.

Share this post


Link to post
Share on other sites

Neither of those seemed to work.

The trigger kept throwing a code error for ST_Dux's solution and Koni's solution just outright didn't work; maybe I'm missing something?

Here's what I did:

Trigger: "CheckpointZombies"

Cond: player in thisList (saying BLUFOR present would mean that the Marines inside the checkpoint would activate the trigger instead of the player)

On Act: (zombie spawn code)

What should I do here?

Share this post


Link to post
Share on other sites

Place a trigger

Axis A & B = whatever area you need for it's radius

Activation = Anybody - Present - Once

Timeout

Min 0 Mid 0 Max 0

Type = None

Name = CheckpointZombies

Condition = player in thislist

On Activation = nul = execvm "myzombiescript.sqf"

That trigger can be named anything you want, as long as it has a name, you can then refer back to it for later use.

Now make a second trigger

Axis A & B = can be set to 0 for each

Activation = Anybody - Present - Once

Timeout

Min 120 Mid 120 Max 120

Type = None

Name = does not need one

Condition = TriggerActivated CheckpointZombies

On Activation = nul = execvm "myzombiescript.sqf"

So this second trigger will activate 120 seconds after the the first trigger called CheckpointZombies has activated.

That way the script will fire twice, but this is a very old way, and now long way of doing things.

---------- Post added at 10:08 PM ---------- Previous post was at 09:59 PM ----------

Another way of doing it with just one trigger, would be to setup the first trigger as above, but say you activate your spawn script like my example

nul = execvm "myzombiescript.sqf"

Make a new file with Notepad or whatever, you already have your spawn script made already, so in this new file just have

nul = execvm "myzombiescript.sqf";

sleep 120;

nul = execvm "myzombiescript.sqf";

sleep 120;

save that new file and call it something simple like

spawn.sqf

Now in the On Activation of the only trigger you're using doing it this way put

nul = execvm "spawn.sqf"

So when the trigger fires, it will read the file and spawn the first zombie script, then wait for 120 seconds, then run the script again spawning more zombies.

Either way works, though it's a very begginers way of doing it, but it works just as well.

Share this post


Link to post
Share on other sites
The trigger kept throwing a code error for ST_Dux's solution

What was the error? Was it something the lines of "Type Script, expected Nothing"? If so, just add "nul = " before the [] spawn {...} part.

Share this post


Link to post
Share on other sites

ST_Dux: that's exactly what it said; I'm new to ArmA scripting (have a bit of experience with C# but from what I can tell this is its own language..) and missed the nul requirement.

I will try both methods and report. Thanks again guys!

Share this post


Link to post
Share on other sites

Fun fact about the "nul requirement": It's not actually a requirement. If you were to put the line in a script without "nul =" and then execute it, it would run just fine. The only reason that error comes up is because the in-game editor has a built-in syntax checker that doesn't know how to deal with extraneous return values. Because execVM returns a script handle, you have to assign it to a variable (it doesn't have to be "nul"; it can be anything) when entering things within in-game editor fields so that the syntax checker has somewhere to put that script handle, thereby "expecting" it.

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  

×