Referring to the latest spitfire script:
line 412
local function ShootWeapon( wTyp, h, toeIn, barrelPos, velocity, numExtraShots, xA, yA, zA )
Basically just uses a particle emitter to generate the 'shot', then uses a raycast to detect if anything is in the firing line and if it is calls the AddTarget function.
line 379
local function AddTarget( h, x, y, z, dist, vel, obj )
Adds the targets to the target list
line 394
local function ProcessTargets( h )
This function is called every frame and generates the particle effect of the bullet hit and if the target is an entity sets the health of the target to 0.
In/Out of cab is simply a different camera position, variables playerPos1 and playerPos2, pressing R key Iline 693) switches between the two positions. The AttachPlayer function (line 239) handles the setting of the camera angle relative to the plane.
Been there, done that, got all the T-Shirts!