I've made progress!
I found something called mouse_dir3d.
So I added:

action b_gun()
{
set(my,PASSABLE);
while(my)
{
vec_for_vertex(me.x, basic, 365);
vec_to_angle(my.pan,mouse_dir3d);
wait(1);
}
}
this works pretty well as the cannon does aim towards my mouse.
The problem now is that the farther away my mouse is from the cannon the higher up it aims!
Does anyone know how to lock the tilt and roll of the cannon or some other way to fix that problem?
I already tried:

my.tilt = clamp(my.tilt,0,0);

and it doesn't work, =(
Thanks for the help
Rtsgamer706