Prize competition help

I'm looking to run a prize competition to win my car ( a very collectable Japanese car) 

I've noticed a few of these popping up and, from what I gather, some have not been legal.

How do I keep mine legal in terms of asking a fairly hard question and then using a random number generator to pick a winner from the correct answer entries. Is this legal ? Or is it using chance?

There will be a ticket price and a maximum number of correct entries allowed and a time frame for all the tickets to be sold in.

If the tickets are not sold in time there will be a cash prize - is this allowed? 

Also what terms and condition template on this website would be appropriate to use to protect myself fully?

As for entries I have friends asking if they would be aloud to enter the competition? Are they OK to enter?

Many thanks for the help.