Jump to content
Sign in to follow this  
_angus_

Trigger fires after set duration or at specific game time?

Recommended Posts

Apologies for what is probably a very basic question, but I wondered if it was possible to trigger an event at a specific time in the game so if I set the game to start a 12.00 noon, can I have something happen at 12.07 for example? Or would I need to somehow have it happen after a seven minute duration?

I have written a mission where the player is hunting for a senior enemy officer, but it isn't until clearing the first suspected location that the player is told the officer is actually somewhere else. Unsure of how to proceed, I have the officer walking some distance between waypoints as a kind of timer - but how would I "create" the officer at a specific time and place?

Thanks for any advice.

Share this post


Link to post
Share on other sites

Perhaps daytime?

Divide the number of spare minutes by 60 to get the decimal value. For your example of 1207, 7/60 = 0.11666... or 0.117.

Spawn your script or call it via execVM. Put a waitUntil above your code in the script:

waitUntil {daytime == 12.117};
<CODE HERE>;

Your code will be executed when the time of day on your server is 1207.

There may be a better/more efficient way to do this. Perhaps a counter or a simple trigger timeout/countdown. Script or trigger, just make sure it is only run on the server.

*edit* - See below!

Edited by Harzach

Share this post


Link to post
Share on other sites
Apologies for what is probably a very basic question, but I wondered if it was possible to trigger an event at a specific time in the game so if I set the game to start a 12.00 noon, can I have something happen at 12.07 for example? Or would I need to somehow have it happen after a seven minute duration?

I have written a mission where the player is hunting for a senior enemy officer, but it isn't until clearing the first suspected location that the player is told the officer is actually somewhere else. Unsure of how to proceed, I have the officer walking some distance between waypoints as a kind of timer - but how would I "create" the officer at a specific time and place?

Thanks for any advice.

In your trigger, change the contents of the condition field to the following:

floor daytime >= [b]12[/b] && floor (60 * (daytime % 1)) >= [b]7[/b];

Then change 12 and 7 to whatever hour and minute you want.

Or if you want seconds too:

floor daytime >= 12 && floor (60 * (daytime % 1)) >= 7 && floor (60 * ((60 * (daytime % 1)) % 1)) >= 34

Then change 12, 7 and 34 to whatever hour, minute and second you want.

Edited by MulleDK19

Share this post


Link to post
Share on other sites
In your trigger, change the contents of the condition field to the following:

floor daytime >= [b]12[/b] && floor (60 * (daytime % 1)) >= [b]7[/b];

.

Thanks guys, much appreciated.

So could I put your line in the condition field:

floor daytime >= 12 && floor (60 * (daytime % 1)) >= 7;

and then in the on activation field:

"BadOfficerDude" createUnit [getMarkerPos "Marker1"]

or would I need to get your line to call up a separate trigger that executed my line?

Again, apologies for my ignorance.

Share this post


Link to post
Share on other sites

Just a heads-up, since the effects of triggers are local, and editor-placed triggers exist on all machines, doing a createVehicle command will result in an object created for each instance of the trigger. So in the event that you have 5 players, you will also spawn 5 BadOfficerDude's. I suggest that you instead, on activation, execVM an .sqf that contains that same line but within a scope that checks for isServer.

Share this post


Link to post
Share on other sites
Thanks guys, much appreciated.

So could I put your line in the condition field:

floor daytime >= 12 && floor (60 * (daytime % 1)) >= 7;

and then in the on activation field:

"BadOfficerDude" createUnit [getMarkerPos "Marker1"]

or would I need to get your line to call up a separate trigger that executed my line?

Again, apologies for my ignorance.

You can do it in this trigger. That's the point. The trigger activates when the time hits 12:07, not when its own settings are met, due to the condition change. Anything in the activation field will execute when it activates.

;2631775']Just a heads-up' date=' since the effects of triggers are local, and editor-placed triggers exist on all machines, doing a createVehicle command will result in an object created for each instance of the trigger. So in the event that you have 5 players, you will also spawn 5 BadOfficerDude's. I suggest that you instead, on activation, execVM an .sqf that contains that same line but within a scope that checks for isServer.[/quote']

That was overly complicated.

For multiplayer, simply change the condition of the trigger to:

isServer && (floor daytime >= 12 && floor (60 * (daytime % 1)) >= 7);

Share this post


Link to post
Share on other sites

Was thinking about if/then not working, didn't even consider the fact that it is just a condition. Thanks for the clarification.

Share this post


Link to post
Share on other sites
You can do it in this trigger. That's the point. The trigger activates when the time hits 12:07, not when its own settings are met, due to the condition change. Anything in the activation field will execute when it activates.

Thanks very much for your patience, guys - very helpful.

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  

×