OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Ice Man 3:16 on 28 Apr 2004, 00:44:31

Title: starting a timer when you use a switch
Post by: Ice Man 3:16 on 28 Apr 2004, 00:44:31
In the mission im working on you have to turn on an animated switch on the side of this one building.  The action name for the switch animation is called "fuelon".  I was wondering if there was a way to make it when you turn the switch on its starts a timer for 5 mins, and when that 5 mins is up its the end of the mission.
Title: Re:starting a timer when you use a switch
Post by: myke13021 on 28 Apr 2004, 01:04:29
does the switch return any variables you could use?
Title: Re:starting a timer when you use a switch
Post by: Raptorsaurus on 28 Apr 2004, 01:24:33
You can make a script that monitors the time as soon as the switch is on. It would look something like this:

@ switchon
_reftime = time

#loop
_checktime = time
?(_checktime - _reftime < 300): goto "loop"
hint "Five minute (300 seconds) has elapsed, switch disengaging"

switchon = false

exit

Title: Re:starting a timer when you use a switch
Post by: Ice Man 3:16 on 28 Apr 2004, 02:24:09
You can make a script that monitors the time as soon as the switch is on. It would look something like this:

@ switchon
_reftime = time

#loop
_checktime = time
?(_checktime - _reftime < 300): goto "loop"
hint "Five minute (300 seconds) has elapsed, switch disengaging"

switchon = false

exit



thats exactly what i need, only as soon as the time elapses i need the mission to end.  how would i do that?
Title: Re:starting a timer when you use a switch
Post by: Raptorsaurus on 28 Apr 2004, 03:38:50
Add another boolean in the script and a trigger in the editor.

@ switchon
_reftime = time

#loop
_checktime = time
?(_checktime - _reftime < 300): goto "loop"
hint "Five minute (300 seconds) has elapsed, switch disengaging"

switchon = false
endgame = true
exit

Then make an end game tigger in the mission that has this in its condition field:

Condition:  endgame


Title: Re:starting a timer when you use a switch
Post by: Ice Man 3:16 on 28 Apr 2004, 04:21:56
It doesn't seem to be working.

I set switch box object on the map,

The command for turning the switch on is switchOpen, It tells the switch to go to do the "on" animation meaning the switch goes down.

this is how it looks in the config.cpp for the switch box

Code: [Select]
      class UserActions
      {
      
         class switchOpen

Lemmie explain the mission im working on.

You have to go to the airport on everon and there is a switchbox.  You pull the switch down and the 5min timer starts, you have to defend the airport for five mins, (the switch box is a fuel switch to refuel a plane) and after that 5 mins the mission is compleate.
Title: Re:starting a timer when you use a switch
Post by: Raptorsaurus on 28 Apr 2004, 19:22:40
you need the config to link to the script that begins the timer.  Unfortunaltely, since I am no expert at config modification I am not sure how you do this, but I have seen it done before.
Title: Re:starting a timer when you use a switch
Post by: Ice Man 3:16 on 28 Apr 2004, 23:19:37
It's cool,  I'll just hook it up to a switch so when youg et close tot eh switch box it starts the timer.

Thanks for all your help :)