The following is probably faulty. It uses a plugin and it may not actually emulate the functionality you seek...?
Reference: eLL
Code:


entity* ent0;
entity* ent1;
function getClosest(_what, &_centerPoint, _radius, &_point) {
var dist0; dist0 = 99999;
var dist1; dist1 = dist0;
ent0 = NULL;
eLLNextReset(_what);
ent0 = eLLNext(_what);
ent1 = NULL;
while(ent0 != NULL) {
if (vec_dist(_centerPoint, ent0.x) <= _radius) {
dist1 = vec_dist(ent0.x, _point);
if (dist1 < dist0) {
dist0 = dist1;
ent1 = ent0;
}
}
ent0 = eLLNext(_what);
}
//ent1 should now be NULL or the closest thing of type _what to _point
/// also in sphere centered at _centerpoint with _radius?
}