Home   Help Search Login Register  

Author Topic: How can I break a loop after a few seconds have past?  (Read 455 times)

0 Members and 1 Guest are viewing this topic.

Anton VonE

  • Guest
The following is a great little snippet that will follow a unit. However, it follows it indefinately...how would I make it stop after 12 seconds?

Anton

;tracking.sqs created by: ???
_unit = _this select 0
_x = _this select 1
_y = _this select 2
_z = _this select 3
stoptracking = false

_cam = "camera" camcreate [0,0,0]
_cam cameraeffect ["internal", "back"]
_cam camSetTarget _unit
_cam CamSetFOV 0.7
 
#loop
~0.01
_cam camSetRelPos [_x,_y,_z]
_cam camCommit 0
? not stoptracking : goto "loop"


_cam cameraeffect ["terminate", "back"]
camdestroy _cam
exit


Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:How can I break a loop after a few seconds have past?
« Reply #1 on: 19 Mar 2003, 01:36:51 »
Well... you could change this line here:

? not stoptracking : goto "loop"

To look like this:

? _time < 12: goto "loop"

That will make the script destroy the camera and exit twelve seconds after the script starts running ;)

Anton VonE

  • Guest
Re:How can I break a loop after a few seconds have past?
« Reply #2 on: 19 Mar 2003, 02:58:48 »
Thank you so much for your help!

Anton