A motorist was caught with cannabis he was to supply to friends a week after appearing before magistrates for having the drug.
Kris Cleverley had three packages of the drug hidden under the engine mounting of his vehicle when it was stopped.
When he was questioned he insisted he had been out to buy it to share with two other friends, one of whom was in the vehicle with him.
Claire Marlow, prosecuting, told Swindon crown court the car was spotted on the A420 on the edge of Chippenham at about 7.30pm on Wednesday March 28.
Officer had been alerted about it so pulled it over and spoke to the driver, who turned out to Cleverley.
He and his passenger were searched, and found to have nothing on them, but the drugs were found under the bonnet.
Below the engine housing police located a bag containing three packages, each with about an ounce of herbal cannabis in them.
When he was questioned by the police he refused to answer their questions but later admitted he had the drugs, weighing a total of 80 grams, to share with two friends.
Cleverley, of Greenway Road, Chippenham, pleaded guilty to possessing cannabis with intent to supply.
The court heard a week earlier he had been put on a conditional discharge by magistrates after he admitted simple possession of more than 46 grams of the drug.
Marcus Davey, defending, said he admitted the offence on the basis that he was getting the cannabis for the passenger and another friend.
He said that his client was at the lowest level of drugs supply.
Passing sentence Judge Douglas Field said: "You were dealing with a limited amount of cannabis to be supplied to a small number of close associates.
"I have decided the best was to deal with you is to try and divert you away from your abiding interest in cannabis and the drug scene by making you the subject of a community order.
"You need some direction and structure in your life. I have to point out to you that is you breach any of the requirements you will be in serious trouble and looking at custody."
He imposed an 18 month community order and told him he would be under the supervision of a probation officer, must do 200 hours of community service and complete a thinking skills programme.