With family I can be whatever I want to be, say whatever I want to say, and they sort of have to take it. It's comforting knowing that you stand to gain nor lose anything.
Being a dick to friends is alright, but if you go too far, you can lose the friendship, so it keeps me on my guard, and makes me do things I wouldn't necessarily do for family.
With strangers, it depends if i want to get anything out of them. If it's just a service they have no control over then I'm neutral. If being nice can benefit me in any way then I'm nice. But if things don't go my way then i turn into a massive prick. Believe it or not you get what you want most of the time by raising hell.