For the tracing part you could try:
Code:
VECTOR trace_from;
VECTOR trace_to;

vec_set(trace_from,vector(mouse_cursor.x,mouse_cursor.y,50));
vec_set(trace_to,vector(mouse_cursor.x,mouse_cursor.y,10000)); // play with the 1000 if the trace is to short

vec_for_screen(trace_from,camera);
vec_for_screen(trace_to,camera);

result = c_trace(trace_from,trace_to,USE_POLYGON|SCAN_TEXTURE);
if(result > 0)
{
  vertex_number = hit.vertex;
}



Now vertex_number contains the closest hit vertex, and you can process it as you like.
Note: not tested!