Roxana Hegeman ?and Maria Fisher

HESSTON, Kan.: A man who stormed into a Kansas factory and shot 14 people, killing three, had just been served with a protective order involving a former girlfriend that probably set off the attack, authorities said Friday.

The assault at the Excel Industries lawnmower-parts plant in the town of Hesston ended when the police chief killed the gunman in a shootout.

Harvey County Sheriff T. Walton described the officer as a “tremendous hero” because 200 or 300 people were still in the factory and the “shooter wasn’t done by any means.”

Had the officer “not done what he did, this would be a whole lot more tragic,” Walton said.

The gunman was identified as Cedric Ford, 38, a worker at the factory. As a convicted felon, he was prohibited from owning any kind of firearm. A woman was charged with supplying him with an assault rifle and a pistol.

Kansas Gov. Sam Brownback said preliminary information indicated that the officer was Hesston Police Chief Doug Schroeder, who did not wait for backup and “seized the situation.”

While driving to the factory, the gunman shot a man on the street, striking him in the shoulder. A short time later, he shot someone else in the leg at an intersection, authorities said.

The suspect shot one person in the factory parking lot before opening fire inside the building, the sheriff’s department said.

Ford had several convictions in Florida over the last decade. His past offenses included burglary, grand theft, fleeing from an officer, aggravated fleeing and carrying a concealed weapon, all from Broward and Miami-Dade counties.

According to the Wichita Eagle, Ford also had criminal cases in Harvey County, including a misdemeanor conviction in 2008 for fighting and various traffic violations from 2014 and 2015.

A Facebook page under the name of a Cedric Ford employed at Excel includes photos posted within the past month of a man posing with a long gun and another of a handgun in a man’s lap.

Sarah T. Hopkins, 28, was in jail awaiting a court appearance Monday on charges that she gave Ford a semi-automatic rifle similar to an AK-47 and a Glock .40-caliber handgun. According to an affidavit, Hopkins lived with Ford in nearby Newton before moving out in July.