The values look like they would fit the if statement.
They really don't, but I have no idea why they're so screwed up. Oh wait... I'm bloody stupid, that's why. What we're doing currently is take the global difference between the vessel and the gate, then convert that to gate-local coordinates. Which of course doesn't work, because it will assume it's a global position. Sorry about that.
I'm away with the family for the weekend, so I don't have the documentation with me, but basically we just have to convert the global coordinates of the vessel to gate relative coordinates. Something like:
Code:
VECTOR3 vesselpos = _V(0, 0, 0);
VECTOR3 gaterelative_pos = _V(0, 0, 0);
oapiGetGlobalPos(hvessel, &vesselpos);
oapiGlobalToLocal(GetHandle(), &vesselpos, &gaterelative_pos);
That should work a lot better. All the rest of that code was to calculate the distance, which we no longer need.