Stop looping animation?

My script tells my animated gun to disable the shooting animation after it has been played 30 times, this works fine except my gun is fully automatic. This means I want my script to know when my animation has looped 30 times instead of being played only once. This is my script, I hope I explained okay…

function Start () {
animation["reload"].speed = 2;
animation["shoot"].speed = 10;
animation["shoot"].wrapMode = WrapMode.Loop;
animation["reload"].wrapMode = WrapMode.Once;
animation["shoot"].layer = 1;
animation["reload"].layer = 2;
animation.Stop();

StartCoroutine(ShotPoller());

}

function ShotPoller () {

while(true){

    if(Input.GetButton("Fire1")){
        Shoot();
        
        yield WaitForSeconds(refireRate);
        
        }else{
   animation.Stop("shoot");
    }
    
    
    if(Input.GetKeyDown("r")){
        Reload();
    }

    yield;
}
}

function Shoot (){

if(Input.GetButton("Fire1")){
  if(bulletsLeft > 0 ){
     bulletsLeft -- ;
     animation.Stop();
     animation.Play("shoot");
   }else{
   animation.Stop();
   }
}

}

var fullClip : int = 30;
var bulletsLeft : int = 30;
var waitTime = 2.5;
var refireRate : float = 0.1;

function Reload () {

if(Input.GetButtonDown("r")){
   animation.Play("reload");
   yield WaitForSeconds(waitTime);
   bulletsLeft = fullClip ;
}
}

Use GetKey insted of using GetButtonDown.

GetKey

Description

Returns true while the user holds down the key identified by name. Think auto fire.