Actor Adam Deacon has been banned from contacting fellow star and director Noel Clarke by a court.
He was found guilty of harassment without violence earlier this year for sending his former friend a "barrage" of abusive social media messages.
The 32-year-old's lawyer said the unemployed star had a "history of mental health difficulties".
He told Hammersmith Magistrates' Court Deacon had "increased his use of skunk cannabis as a form of self medication".
Deacon was sectioned under the Mental Health Act in January and has been diagnosed with bipolar disorder, the court heard ahead of today's sentencing.
Noel Clarke previously told the court that he helped launch Deacon's career by selecting him to star in his hit films Kidulthood and Adulthood.
The pair fell out in 2010 over a spoof film Deacon wanted to make called Anuvahood.
Deacon made the movie and won a Bafta, but still took to Instagram and Twitter to attack the Doctor Who star - accusing his friend of "bullying" him and "sabotaging" his career.
"Perhaps Mr Deacon had justifiable reasons for feeling aggrieved towards Mr Clarke, perhaps he did not," said Oscar Merry, speaking for Deacon in court.
"What is clear is that his online trolling of Mr Clarke overstepped the mark from unreasonable behaviour to actions that were unacceptable."
Noel Clarke said he'd tried to ignore the abuse, but Deacon posted pictures of his children next to an emoji of a gun.
"It is a death threat isn't it, really? If we are being honest," he told the court during Deacon's trial.
Following this, the security codes were changed at the school attended by Noel Clarke's children.
Deacon's lawyer called his client a "decent and kind human being" and said the trolling was "totally out of character".
He said Deacon was "profoundly ill" and having a "full mental breakdown" at the time of the abuse.
Even after the police were called in, Deacon continued to troll Noel Clarke, calling him a "snitch".
See these BBC Advice pages for help and guidance on depression and mental health issues.