You can do something similar entity side, but someone asked me how to do it via script, so here you go.
This script includes
findsurvivors.nut, so be sure to grab that too.
Here's how you would use it.... (or one way to, you can use triggers as well and all that
IncludeScript("survivorclosest.nut", this);
ent <- Entities.FindByName(null, "entname");
printl("Found entity "+ent);
FindSurvivors() // make sure this script isn't called right away or they won't be found yet
who <- FindSurvivorClosestToEnt(ent); // returns entity reference to survivor
if (who){
printl(who);
printl(who+" is closest to "+ent.GetName()+" at "+who.GetOrigin());
// do something here
}else{
printl("Nothing found");
}
/* or, if you want the name returned (the key into the
survivors table), add a true value as a second param */
who <- FindSurvivorClosestToEnt(ent, 1); // returns entity reference to survivor
if (who){
printl(who);
printl(who+" is closest to "+ent.GetName()+" at "+survivors[who].GetOrigin());
// do something here
}else{
printl("Nothing found");
}