"Okay, so first of all I don't know Riften's city code so when you open the cheat console type in 'help' 'city name' '4' in that order. This will give you a list of cities and their codes, find the one for Riften and write it down on a scrap sheet of paper
Then type in the following cheat code
player.setcrimegold XXX <faction id>- Set it high if you want to fight, set it at 0 if you want to be free.
example: player.setcrimegold 0 insertcityid#here and you won't have any problems.
IMPORTANT: Always, always, always save your game before you use any cheat in case the file becomes corrupted. I would advise you to try and play through it to get the full experience of the game, but I understand how annoying it is to be attacked on sight while your trying to complete a quest or something. Good luck. Feel free to pm me if you need anymore help. Source(s):"