NPC Code:
if(weaponfired && !this.on == 1){
initialise();
timeout = 0.1;
}
That is the on/off function, but its only scripted to go on.
You can use an algorithim for making a 1 and 0 toggle for the this.on variable with something such as:
this.on = abs(this.on-1);
Plug that in there. Make sure initialise() only happens if this.on is '1'. If this.on is '0', make an end function such as end() that unsets everything that happening (one thing in that function could be hideimg 200)