Function I wrote ages ago:
overObj.sqf
private ["_pos","_dist","_type","_buf","_breakflag","_objs","_obj","_j","_c","_xmin","_xmax","_ymin","_ymax","_zmin","_zmax","_mpos","_mx","_my","_mz","_wz","_return"];
_pos = _this select 0;
_type = _this select 1;
_dist = _this select 2;
_buf = [0,0,0];
if (count _this > 3) then {_buf = _this select 3;};
_breakflag = TRUE;
_objs = nearestObjects [_pos, _type, _dist];
for [{_j = 0},{_j < count _objs && _breakflag},{_j = _j + 1}] do
{
_obj = _objs select _j;
_c = boundingBox _obj;
_xmin = ((_c select 0) select 0) - (_buf select 0);
_xmax = ((_c select 1) select 0) + (_buf select 0);
_ymin = ((_c select 0) select 1) - (_buf select 1);
_ymax = ((_c select 1) select 1) + (_buf select 1);
_zmin = ((_c select 0) select 2) - (_buf select 2);
_zmax = ((_c select 1) select 2) + (_buf select 2);
_mpos = _obj worldToModel _pos;
_mx = _mpos select 0;
_my = _mpos select 1;
_mz = _mpos select 2;
if (_mx > _xmin && _mx < _xmax && _my > _ymin && _my < _ymax) then
{
_breakflag = FALSE;
_wz = (_obj modelToWorld [0,0,_zmax]) select 2;
};
};
[not _breakflag, _wz, if _breakflag then {objNull} else {_obj}]
Initialize it somewhere, maybe init.sqf
overObj = compile preProcessFileLineNumbers "overobj.sqf";
Call it like so:
_return = [_pos, _type, _dist] call overObj;
where _pos is a 3D position, so if you are using a marker you must add a 0 for height, _type is the object class you want to test against, in your case "All", and _dist is how far away you want to search. _dist should be set to something like 50.
_return select 0;
True if inside object, False othewise
_return select 1;
Height above object. You don't need this.
_return select 0;
Intersecting object position is inside. Will be objNull if _return select 0 is False.
All commands that search for objects are laggy, so you do not want to run them constantly. What you need to do is call the function only when a player dies, making sure the respawn delay is set high enough.