The first thing that comes to my mind is to separate the track on parts defined in a file (or maby arrays if you cant use databases yet

)Check to see where on the track the player is , and you defined the needed pan on that part(min_x,min_y,min_z and max_x,max_y,max_z) and if it is > player.pan + 90 or player.pan - 90 then display that the player is going in the wrong direction.
As for the AI , I would suggest something like robby. But it will need a lot of scripting to make it for cars and effective.

With paths the cars will go every time on the same path and if you make the paths on the shortest fastest way cutting corners...etc. the player wont be able to beat them and also every time it'll be the same.