This should work:
// myshells.sqf
private["_myshell", "_pos_shell"];
_myshell = _this select 0;
if (local (_this select 1)) then
{
while {!isNull _myshell} do
{
_pos_shell = getPos _myshell;
Sleep 0.001;
};
hint format["Distance: %1m", ((_this select 1) distance _pos_shell)];
};
//init.sqf
myunit addEventHandler ["Fired", {[(nearestObject[_this select 0, _this select 4]), _this select 0] execVM "myshells.sqf"}];