Fps game: goto after 5 shoots or 20 seconds

Hi

I’m working on a simple first person game - converting it to a banner ad.

I’d like the timeline to move to an end game frame after 5 shoots or after 20 seconds - any ideas on how the script below controlling the game can be modigied to achieve this?

Thanx

Dirk

var i;
// gunfire sounds
var gunfire = new Sound();
gunfire.attachSound("gunfire");
_root.hit1.onPress = function() {
    gunfire.start();
    i++;
    
    _root.bull.duplicateMovieClip("bulletNew", i);
    if (i == 10) {
        i = 0;
    }
    // hit test on target
    if (_root.target_mc.hitTest(_root._xmouse, _root._ymouse, false)) {
        _root.gun.gotoAndPlay(2);
        _root.target_mc._x = 0;
        _root.target_mc._y = random(90);
    }
};
// initialise stuff
_root.onLoad = function() {
    // hide the mouse
    Mouse.hide();
};
//loop
_root.onEnterFrame = function() {
    //put cross hairs to mouse coords
    _root.gun._x = _root._xmouse;
    _root.gun._y = _root._ymouse;
    // target move
    _root.target_mc._x += 10;
    if (_root.target_mc._x<0 || _root.target_mc._x>Stage.width) {
        _root.target_mc._x = 0;
        _root.target_mc._y = random(90);
    }
    
};