-- Returns true if another human player (that is *not* on your -- friend list) is within the range specified. -- If range is not given, assume 500 units. function CPlayer:isHumanInRange(_range) _range = _range or 500; -- Returns true if (x2,y2) is within 'radius' of (x1,y1) -- This should be slightly faster than the standard distance -- forumla. local function isInDist(x1, y1, x2, y2, radius) if( x2 >= x1-radius and x2 <= x1+radius and y2 >= y1-radius and y2 <= y1+radius ) then if( ((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)) <= radius*radius ) then return true; else return false; end end return false; end local obj = nil; local objectList = CObjectList(); objectList:update(); for i = 0,objectList:size() do obj = objectList:getObject(i); if( obj.Type == PT_PLAYER and obj.Address ~= self.Address ) then if( isInDist(self.X, self.Z, obj.X, obj.Z, _range) ) then return true; end end end return false; end