(global short limit 30)
(global short p0flashlight 0)
(script static "unit" player
(unit (list_get (players) 0))
(script continuous flashlightusage
(if (unit_get_current_flashlight_state (player)) (set p0flashlight (+ p0flashlight 1)) (if (> p0flashlight 0) (set p0flashlight (- p0flashlight 1))))
(if (>= p0flashlight limit) (unit_set_desired_flashlight_state (player) 0))
Set the variable limit at the top to what ever duration you require. It's currently only setup for player0 (newest joined player) but you get the idea from it if you need to set it up for MP.
If there flashlight is on, make the flashlight variable 1 higher than it currently is, if not, make it one lower as long as the flashlight variable isnt lower than 0. Then if the flashlight record is larger or equal to the limit, forcibly turn the flashlight off.