the method of active_tri like this :

when you hit enter and active_tri = 0 then the variable turn to 1 (active_tri = 1)

and if active_tri = 1 your model should play "on" animation and when he fenish it he turn the var active_tri to 2.

and if the variable active_tri = 2 and you hit enter the active_tri turn to 3 so its play animation "off" and when he finish it , it turn variable active_tri to 0 so its the begining.