A Sunderland man who groomed a 14-year-old for sex was arrested as he stepped off a bus after travelling 260 miles to see her.
For while Michael Smith, 18, was en route to meet the girl, her father learnt of the planned rendezvous and locked her in the house to prevent it, Gloucester Crown Court was told.
The girl rang the police, claiming she was being unlawfully imprisoned, said prosecutor Christopher Smythe.
But when officers arrived at her home to check out her story they found out about Smith and went to Cinderford bus station, where they arrested him as he stepped off the vehicle.
Smith, who has been in custody since his arrest in March, admitted grooming the girl and travelling to meet her for the purpose of carrying out a sexual act.
Mr Smythe said Smith was living in a hostel for the homeless in Sunderland when he befriended the girl on Facebook.
"There was sexual chat and then over a period of four days between 18-22 March there were 663 messages between them," Mr Smythe said.
"In them he indicated he wanted to have sex with her. She was persuaded to ask her dad if he could come and stay. She told her dad he was 16, not 18.
"He travelled down, but the girl's father was concerned and locked her in the house. He didn't want her to meet the defendant.
"She rang the police and complained her father had falsely imprisoned her. The police went to check up on it, heard about Smith being on the way, and went to the bus station and arrested him as he arrived.
"The search history on his phone found he had been looking at some disturbing material."
After hearing that Smith's father, Robert, a lecturer in Worcester, is prepared to let him live with him, Judge Jamie Tabor QC passed a 12-month detention sentence, suspended for two years.
He also ordered Smith, who was of previous good character, to attend a 70-session programme requirement to address his offending behaviour and a 30-day rehabilitation activity requirement.
Smith was ordered to attend the Worcester probation office for his first appointment on Monday. He will have to sign the sex offenders' register for the next 10 years.
The judge warned Smith that if he breaches the terms of the order in any way, he will be returned to court and sent to detention.