Police swooped on a quiet street in the middle of the night after an online gamer pulled off an elaborate hoax on an internet friend.

Robert Barr sent a full turnout of emergency services to the £400,000 house Jamie Sales shares with his family near Monifieth, Angus, as he lay sleeping in his bed.

Barr claimed to 999 call handlers that he was Jamie Sales and that his father had attacked his mother and was coming for him with a knife.

In reality, Barr was at his home 100 miles away in Paisley, Renfrewshire, while the Sales family were sleeping.

Fiscal depute Kirsten Thomson told Forfar Sheriff Court Barr and Mr Sales had become friends online and made various prank calls to businesses and takeaways.

Their online fun turned sour when Barr made a bogus call to police and sent them to Mr Sales' home before going on social media minutes later and writing: "I'm going to prison."

Ms Thomson said: "The complainer had been a friend of the accused and they had met through online gaming, and spoke through Skype and on the Xbox.

"They were making prank calls to businesses and fast food outlets and were listening to each other.

"At 2.30am on July 27, 2014, a police call handler in Glasgow received a call from a withheld number.

"On answering the operator obtained initial details and the accused identified himself as Mr Jamie Sales, of Taymouth House, Monifieth."

Barr told police his father had knocked his mother unconscious and that he was coming upstairs with a knife.

Ms Thomson added: "Due to the severity of the incident an immediate police and ambulance response was requested and police attended immediately."

Mr Sales' mother, Michelle, was said to be "quite startled" to hear from police when they called her phone and turned up at her home.

Barr, 19, of Kilbirnie, Renfrewshire, pleaded guilty to a charge of wasting police time on July 27, 2014.

He further admitted a charge of breaching a bail order imposed on him with conditions not to access the internet.

The court heard he broke that order last year after he formed an online relationship with an American woman and arranged for her to come and meet him at Glasgow Airport.

Miss Thomson said: "Police officers were in the airport and Barr was sitting waiting in international arrivals."

Sheriff Pino di Emidio imposed a community payback order with 120 hours' unpaid work.

He said the case involved a "very serious incident" and described it as an "elaborate hoax".

It is the second time the Sales family had been targeted by so-called friends in the space of months.

Mrs Sales was the victim of a £23,000 theft by friend Susan Beattie just nine months earlier when the family were in Lanzarote.