This is the correct way to do it:
function worldToScreen(%eyeTransform, %worldPosition, %screenExtent, %cameraFoV)
{
%offset = MatrixMulVector("0 0 0" SPC getWords(%eyeTransform, 3, 5) SPC -1 * getWord(%eyeTransform, 6), VectorSub(%worldPosition, %eyeTransform));
%x = getWord(%offset, 0);
%y = getWord(%offset, 1);
%z = getWord(%offset, 2);
%fovFactor = %y * (%cameraFoV != 90 ? mTan(%cameraFoV * $pi / 360) : 1);
%screenWidth = getWord(%screenExtent, 0);
%screenHeight = getWord(%screenExtent, 1);
%screenX = ((%x / %fovFactor) + 1) / 2 * %screenWidth;
%screenY = ((%z / %fovFactor * %screenWidth) - %screenHeight) / -2;
return %screenX SPC %screenY;
}
If you're trying to do this client-side only, you need to calculate the eye transform. Of course, you shouldn't be messing with this kind of thing in the first place if you do not fully understand the math behind it. Otherwise, you end up wasting time trying to experiment and guess how to do it.