OAKLAND — A Sacramento-area man was sentenced to 18 months in federal prison Thursday, a year after he sold two homemade guns to an undercover federal agent.

Allan Rivers made the guns using tutorials on Youtube, according to his attorney. Federal prosecutors say in July and August 2017, Rivers sold three guns to an undercover agent with the Bureau of Alcohol, Tobacco, Firearms and Explosives.

Two sales went down in Sacramento, while a third took place at a Chevy’s in Richmond, according to court records.

The guns are described by federal prosecutors as machine guns, including an Uzi. Rivers’ attorney, though, described them more as amateur attempts at machine guns, and said ATF agents were unable to get them to function properly during test firing.

Rivers’ attorney asked for a probation sentence. Prosecutors wanted a prison term of 37 months. U.S. District Judge Yvonne G. Rogers’ sentence of 18 months prison and three years supervised release was right in the middle.

Prosecutors asked for a longer sentence, saying Rivers told the undercover agent he planned to make fully automatic AR-15 rifles and Glock pistols, and asked the agent if he was a member of a Filipino gang in San Francisco before going through with a buy.

Rivers’ attorney, Jerome Matthews, described his client as a devoted family man who had turned to selling guns out of a dire financial situation. He wrote that the guns weren’t as dangerous as federal prosecutors made it sound.

“This record confirms that Mr Rivers is a rank amateur who, in a fit of financial desperation, produced poorly machined firearms that barely functioned as manual weapons, much less machine guns,” Matthews wrote, according to court records.