Jump to content
Sign in to follow this  
Nicolai

Trigger activate every 60 seconds

Recommended Posts

ok please help me out guys...

I would just like to have a trigger that activates every 60 seconds.. I have tried everything, maybe I'm just stupid but please.. help me out :(

Thanks in advance...

Nicolai

Share this post


Link to post
Share on other sites

Quick answer. Use more than 1 trigger. 1st 60sec, 2nd 120 sec, 3rd 180 sec, and so on. Or you try a script for this.

Share this post


Link to post
Share on other sites

I seem to remember that triggers by default check their own status once per second. That sounds a little low to me, so that's probably not true, but let's say it is (it's bound to be some value).

I think that instead of directly using a trigger, that maybe you should loop a script that checks the status of a trigger each 60 seconds, and controls the activity from there.

So you have your trigger set up, named, and you have a script that does (something like):

while {true} do
{
if (triggerName) then
  {
     ...code...
  };
sleep 60;
};

Edited by DMarkwick

Share this post


Link to post
Share on other sites

I will try this DMarkwick, thanks

Question: The script should be executed by something, the trigger itself?

Edited by Nicolai

Share this post


Link to post
Share on other sites
Question: The script should be executed by something, the trigger itself?

It can be activated by anything, place the exeVM call into any object's init field, or place the call in the mission's init.sqf file. If the mission doesn't have one, make one :)

Share this post


Link to post
Share on other sites

If you don't want to script a trigger then an easy way is as follows.

In the init box of a game logic or unit setup up a variable ie var1=true

Then set your trigger conditions, anyone present not present ect and set all timers to 60 and make sure you select repeating

Then put the following code in the correct boxes

Cond this and var1

On Act var1=false

On Dea var1=true

Con can also be just var1 if you don't need all the triggers settings.

Edited by F2k Sel

Share this post


Link to post
Share on other sites

that is simply brilliant, can't understand why I can't come up with something simple like that. Thanks all for your help :thumb:

Nicolai

Share this post


Link to post
Share on other sites

can a trigger only be activated for a couple of times? It works perfectly, for about 6 times, after then, the trigger is no longer activated. Suggestions?

Thanks

Nicolai

Share this post


Link to post
Share on other sites

ok I have a unit "unit1" and a popup target "target1" which has allowDamage = false.

In the init line of unit1 I have:

unit1 dofire target1

I have a game logic with var1=true in its init line.

I have a trigger with blufor present, repeatedly, timeout, 60,60,60

cond:

this and var1

OnAct:

removeAllWeapons unit1; unit1 addWeapon "M16A4"; unit1 addMagazine "30Rnd_556x45_Stanag"; unit1 addMagazine "30Rnd_556x45_Stanag";   unit1 addMagazine "30Rnd_556x45_Stanag"; var1=false

note the var1=false in the end

OnDea:

var1=true

unit 1 is located inside the trigger area

I'm trying to make the unit shoot the target once in a minute, therefore I (think) I have made a trigger that gives the unit the apropriate ammo every 60 seconds and tells it to fire at the target.

This works, but only for about 5 or 6 times

thanks in advance,

Nicolai

Share this post


Link to post
Share on other sites

If you want something specific to happen once a minute you really should just use a looping script that has a sleep 60; line in it. The script should be executed from wherever you like it to be executed - if you want it to happen all the time execute it from init.sqf. Then you can also add whatever condition you like, for example:

shoot.sqf

shouldIshoot=false;
while {true} do
{
  sleep 60;
  if (shouldIshoot) then
  {
     // do whatever
  };
};

Then whenever you set the shouldIshoot variable to true the script will fire every 60 seconds, and when it is false it will not fire. If you want the script to shoot as soon as the condition is true, though, you can do:

shouldIshoot=false;
while {true} do
{
  waitUntil {shouldIshoot};
  // do whatever
  sleep 60;
};

And there are a million other options to do this depending on what you actually want to do. Just make sure in the init.sqf you have a line execVM shoot.sqf;

Share this post


Link to post
Share on other sites

I've actually just tested it and it works fine here.

The odd thing is that if I then make that unit a player it gets no ammo added.

Edited by F2k Sel

Share this post


Link to post
Share on other sites

does a script like that auto loop? or do you have to put a loop command behind the code?

btw thanks everyone for being so helpful!

Nicolai

edit: I found out it auto loops, it all works like a dream now, thanks a million everyone!

Edited by Nicolai

Share this post


Link to post
Share on other sites
does a script like that auto loop? or do you have to put a loop command behind the code?

btw thanks everyone for being so helpful!

Nicolai

Yes it does, because the conditional "while {true} do" is testing the status of "true" which is a BIS reserved value meaning true. So as long as true is true, the code within the curly brackets will execute, which is why you should always put a sleep in there somewhere or you could bog down the game with a minor bug :D

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  

×