A teenage drug dealer who was caught armed with two knives and a loaded pistol has walked free from court.

James Parish had the imitation firearm tucked into his waistband when he was stopped in a friend's car in the middle of the night.

But after hearing the 18-year-old is on the autistic spectrum and would struggle in custody Judge Robert Pawson imposed a community order.

Colin Meeke, prosecuting, told Swindon Crown Court how police were on patrol shortly after midnight on Friday Aug 4 last year.

They spotted a car with only one headlight out on Whitworth Road, near the Moonrakers, and when they pulled it over picked up the strong smell of cannabis.

Inside the vehicle they recovered a bag which contained two knives, cash, a roll of tine foil and some cannabis.

"Mr Parish indicated to the officers an imitation firearm, a gas powered BB gun which he had stuffed in the waistband of his trousers," he said.

Although not a genuine gun he said that it looked genuine, was ready to fire, and had ammunition in the chamber.

"The defendant's home address was searched and various paraphernalia connected with drug dealing were found, and quantities of drugs also."

The cannabis was in street deals and his mobile phone had numerous phone numbers where after the name was 'shot', which is street slang for dealing.

Hundreds of emails and texts related to drugs, and thousands of pounds were paid into his bank account by a number of customers: one labelling the transaction 'cannabis'.

He said the communications showed he had been involved in the trade for between a year and 18 months,

When he was questioned he said he and his pal were going to smoke the drugs found on him and he had the knives on him for protection because of spiralling crime rates.

And he said that he only had the gun with him to shoot at tin cans and bottles, which he claimed he had been doing that day.

Mr Meeke said "That may be as unlikely as the explanation he gave for the drugs," to which the judge replied 'It is poppycock, isn't it'.

Parish, of Windflower Road, pleaded guilty to being concerned in the supply of drugs, having an imitation firearm and possessing two knives.

David Maunder, defending, said his client came from a respectable family, who he lives with, and has a job.

He said that he was 16 and 17 years old at the time of the offending and was on the autistic spectrum.

Passing sentence the judge said "You were risking being involved in other people suffering from mental illness, from psychosis.

“You were also stupid enough to be out with an imitation firearm. I have seen the photographs: anyone who had that pointed at them would assume it is genuine.

“You were armed not because you were concerned in the rise in local crime but you were armed because you were involved in the drugs trade.

“If you were involved in the drugs trade then you were worried about other people trying to get your money or drugs. If you lay down with dogs you get fleas.”

He said he would not jail him because of his age, his condition on the autistic spectrum and concerns about his ability to cope inside.

He imposed a two year community order with 150 hours of unpaid work and 40 days of rehabilitation activity requirement.