Шаг за шагом реши проблему.
[ML] (error) Z.lua: opcode '01BB' call caused an unhandled exception
stack traceback:
[C]: in function 'getObjectCoordinates'
...rams\Arizona Games Launcher\bin\arizona\moonloader\Z.lua:68: in function 'isPlayerNearObject'
...rams\Arizona Games Launcher\bin\arizona\moonloader\Z.lua:179: in function <...rams\Arizona Games Launcher\bin\arizona\moonloader\Z.lua:168>
[ML] (error) Z.lua: Script died due to an error. (0E3382D4)

```lua
function contains(table, value)
    for _, v in ipairs(table) do
        if v == value then return true end
    end
    return false
end

function isAngleInRange(angle, range)
    return angle >= range[1] and angle <= range[2]
end

function fix(angle)
    return angle % (math.pi * 2)
end

function GetCoordinates()
    if isCharInAnyCar(playerPed) then
        local car = storeCarCharIsInNoSave(playerPed)
        return getCarCoordinates(car)
    else
        return getCharCoordinates(playerPed)
    end
end

function GetNearestObject(distance, modelIds)
    local nearestObject = nil
    local nearestDist = distance
    local x, y, z = getCharCoordinates(playerPed)
    for _, obj in ipairs(getAllObjects()) do
        local modelId = getObjectModel(obj)
        if modelId and contains(modelIds, modelId) then
            local _, ox, oy, oz = getObjectCoordinates(obj)
            local dist = getDistanceBetweenCoords3d(ox, oy, oz, x, y, z)
            if dist < nearestDist then
                nearestDist = dist
                nearestObject = {dist, ox, oy, oz}
            end
        end
    end

    if nearestObject then return true, unpack(nearestObject) end
    return false
end

function checkObjectsInRadius(radius, targetModelIDs)
    local playerX, playerY, playerZ = getCharCoordinates(PLAYER_PED)
    if type(playerX) ~= "number" or type(playerY) ~= "number" or type(playerZ) ~= "number" then
        sampAddChatMessage("Ошибка: getCharCoordinates вернул неверные значения.", -1)
        return false
    end

    for _, object in ipairs(getAllObjects()) do
        if doesObjectExist(object) then
            local _, objectX, objectY, objectZ = getObjectCoordinates(object)
            local distance = getDistanceBetweenCoords3d(playerX, playerY, playerZ, objectX, objectY, objectZ)
            if distance <= radius then
                local objectModel = getObjectModel(object)
                if contains(targetModelIDs, objectModel) then return true, object, {objectX, objectY, objectZ} end
            end
        end
    end

    sampAddChatMessage("Нет объектов в радиусе " .. tostring(radius), -1)
    return false
end

function isPlayerNearObject(object, radius)
    local success, objectX, objectY, objectZ = getObjectCoordinates(object)
    if not success then return false end
    local playerX, playerY, playerZ = getCharCoordinates(PLAYER_PED)
    for _, player in ipairs(getAllChars()) do
        if doesCharExist(player) and not isCharDead(player) and player ~= PLAYER_PED then
            local playerDistance = getDistanceBetweenCoords3d(objectX, objectY, objectZ, playerX, playerY, playerZ)
            if playerDistance <= radius then return true end
        end
    end
    return false
end

local keysData = {
    [1024] = {
        structElement = 4,
        size = 2
    },
    [32] = {
        structElement = 4,
        size = 2
    }
}

function sendkey(keyCode)
    local _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
    local mem, data = allocateMemory(68), keysData[keyCode]
    if data then
        sampStorePlayerOnfootData(id, mem)
        setStructElement(mem, data.structElement, data.size, keyCode, false)
        sampSendOnfootData(mem)
        setStructElement(mem, data.structElement, data.size, 0, false)
        sampSendOnfootData(mem)
    end

    freeMemory(mem)
end

function MovePlayer(move_code, isSprint)
    setGameKeyState(1, move_code)
    if isSprint then setGameKeyState(16, 255) end
end

function setAngle(targetX, targetY, distance, speed)
    local sourceX = fix(representIntAsFloat(readMemory(0xB6F248, 4, false)))
    local sourceZ = fix(representIntAsFloat(readMemory(0xB6F258, 4, false))) + math.pi
    local angle = GetAngleBeetweenTwoPoints(targetX, targetY) - sourceZ - math.pi
    local baseCameraPositionZ = fix(representIntAsFloat(readMemory(0xB6F258, 4, false)))
    if distance > 1.8 then
        if isAngleInRange(angle, {-0.1, 0.03}) or isAngleInRange(angle, {-5.7, -5.93}) or isAngleInRange(angle, {-6.0, -6.4}) then
            setCameraPositionUnfixed(-0.3, GetAngleBeetweenTwoPoints(targetX, targetY))
        elseif angle > 0.04 or isAngleInRange(angle, {-3.5, -5.67}) then
            setCameraPositionUnfixed(-0.3, baseCameraPositionZ + speed)
        else
            setCameraPositionUnfixed(-0.3, baseCameraPositionZ - speed)
        end
    else
        setCameraPositionUnfixed(sourceX, GetAngleBeetweenTwoPoints(targetX, targetY))
    end
end

function GetAngleBeetweenTwoPoints(targetX, targetY)
    local charX, charY = getCharCoordinates(playerPed)
    local deltaX = targetX - charX
    local deltaY = targetY - charY
    local angle = math.atan2(deltaY, deltaX)
    return angle
end

function findNearestOre()
    local found, _, x, y, z
    repeat
        wait(0)
        found, dist, x, y, z = GetNearestObject(50, {854, 3930})
        printStringNow("Ore Search...", 5)
    until found
    return found, x, y, z
end

function BeginToPoint(targetX, targetY, targetZ, radius, move_code, isSprint)
    local botActive = true
    while botActive do
        local posX, posY, posZ = GetCoordinates()
        if posX == nil or posY == nil or posZ == nil then
            botActive = false
            break
        end

        local dist = getDistanceBetweenCoords3d(targetX, targetY, targetZ, posX, posY, posZ)
        setAngle(targetX, targetY, dist, 0.1)
        MovePlayer(move_code, isSprint)
        if dist < radius or findAllRandomCharsInSphere(targetX, targetY, targetZ, 4, false, true) then botActive = false end
        wait(0)
    end
end

function main()
    while not isSampAvailable() do
        wait(0)
    end

    sampRegisterChatCommand("mainbot", function()
        lua_thread.create(function()
            local found, _, oreX, oreY, oreZ = findNearestOre()
            if not found then
                sampAddChatMessage("Руда не найдена в радиусе.", -1)
                return
            end

            while true do
                wait(0)
                local playerX, playerY, playerZ = getCharCoordinates(PLAYER_PED)
                local playerDistance = getDistanceBetweenCoords3d(playerX, playerY, playerZ, oreX, oreY, oreZ)
                if isPlayerNearObject(obj, 4) then
                    sampAddChatMessage("Игроки рядом с рудой. Игнорируем.", -1)
                    break
                end

                if playerDistance > 2.5 then
                    sampAddChatMessage("Нашел руду, рядом игроков нет, бежим туда.", -1)
                    BeginToPoint(oreX, oreY, oreZ, 1, -255, false)
                else
                    sampAddChatMessage("Достиг руды, начинаю копать!", -1)
                    sendkey(1024)
                    break
                end
            end
        end)
    end)

    while true do
        wait(0)
    end
end
```