The 24-year-old cop was sitting in his car at Steinway St. and 23rd Ave. in Astoria when the gun discharged about 1 a.m. , officials said.