Thanks to
UnioDex pointing out and coming up with solution. So all credits for this fix goes to him.
Added extra protection to prevent players, who are in trade mode, from sending chat messages or performing commands. This should minimize possibilities for hacked clients to send actions they should not have access too while trading.