Неактуально SA:MP Arizona [Lua] DB Helper | Помощник для дальнобойщика [Полностью легальный]

awa

Участник
13
2
Аааа, а что делать теперь?

Добавить:
parse:
function parseMoneyFromServerFormat(text)
    local total = 0
    local m = text:match(":M:%s*(%d+)")
    if m then total = total + tonumber(m) * 1000000000 end
    local kk = text:match(":KK:%s*(%d+)")
    if kk then total = total + tonumber(kk) * 1000000 end
    local k = text:match(":K:%s*([%d%.]+)")
    if k then
        local clean_k = k:gsub("%.", "")
        total = total + tonumber(clean_k)
    end
    return total
end

Заменить:
se.onServerMessage:
function se.onServerMessage(color, text)
    if not isSessionActive then return end

    if settings.custom and settings.custom.triggers then
        for _, trigger in ipairs(settings.custom.triggers) do
            local safePattern = trigger.text:gsub("([%(%)%.%%%+%-%*%?%[%^%$])", "%%%1")
            safePattern = safePattern:gsub("{СУММА}", "(%%d+)")
            safePattern = safePattern:gsub("{ЧИСЛО}", "(%%d+)")

            if text:find(safePattern) then
                local amount = text:match(safePattern)
                if amount then
                    curSessionMoney = curSessionMoney + tonumber(amount)
                    sampAddChatMessage(prefix.."Поймана набавка: "..amount.."$", -1)
                end
            end
        end
    end

    if text:find("Ваша зарплата за рейс") then
        isTripActive = false

        local salary = parseMoneyFromServerFormat(text)
        if salary and salary > 0 then
            curSessionMoney = curSessionMoney + salary
            curSessionDeliveries = (curSessionDeliveries or 0) + 1
            lastDeliveryTime = os.time()
        end

        if cbAutoRelog[0] then
            sampAddChatMessage(prefix .. "Рейс окончен. {FFD700}Авто-релог через 5 секунд...", -1)
            settings.isRelogging = true
            saveConfig()
            reconnect(5000)
        end
        return
    end

    if text:find("Вы получили транспорт на базе") then
        currentTripStart = os.time()
        isTripActive = true
    end

    if text:find("Вы получили предмет") and text:find("Откройте инвентарь") then
        local foundBoxKey = nil

        if text:find(":item9770:") or text:find(":item9769:") then
            if os.time() - lastDeliveryTime <= 5 then
                curSessionDividends = curSessionDividends + 1
                sessionDividendMoneyEarned = sessionDividendMoneyEarned + settings.dividendPrice
            end
        end

        for _, box in ipairs(lootboxList) do
            if text:find(box.id) then
                foundBoxKey = box.key
                break
            end
        end

        if foundBoxKey then
            if os.time() - lastDeliveryTime <= 5 then
                curSessionLootboxes = curSessionLootboxes + 1
                local price = settings.lootPrices[foundBoxKey] or 0
                sessionLootMoneyEarned = (sessionLootMoneyEarned or 0) + price
            end
        end
    end
end
Скрипт все еще очень крутой, как хелпер но требует переработки
Авто-открытие ворот больше не требуется, сервер сам открывает (Не уверен)
Авто-спорт кривая реализация
Аренду с оптимусом вроде как не пофиксил
Подсчет ларцов/дивидентов - требуется переработка, тк ларцы сейчас поступают в хранилище, а дивиденты после получения первого в инвентарь, в чате не отображаются
Кривой авто-релог, даёт банчик ип

За крутую базу для читиков однозначно лайкец <3
1777487064861.png
 
Последнее редактирование:

Kermi

Активный
Автор темы
275
75
Добавить:
parse:
function parseMoneyFromServerFormat(text)
    local total = 0
    local m = text:match(":M:%s*(%d+)")
    if m then total = total + tonumber(m) * 1000000000 end
    local kk = text:match(":KK:%s*(%d+)")
    if kk then total = total + tonumber(kk) * 1000000 end
    local k = text:match(":K:%s*([%d%.]+)")
    if k then
        local clean_k = k:gsub("%.", "")
        total = total + tonumber(clean_k)
    end
    return total
end

Заменить:
se.onServerMessage:
function se.onServerMessage(color, text)
    if not isSessionActive then return end

    if settings.custom and settings.custom.triggers then
        for _, trigger in ipairs(settings.custom.triggers) do
            local safePattern = trigger.text:gsub("([%(%)%.%%%+%-%*%?%[%^%$])", "%%%1")
            safePattern = safePattern:gsub("{СУММА}", "(%%d+)")
            safePattern = safePattern:gsub("{ЧИСЛО}", "(%%d+)")

            if text:find(safePattern) then
                local amount = text:match(safePattern)
                if amount then
                    curSessionMoney = curSessionMoney + tonumber(amount)
                    sampAddChatMessage(prefix.."Поймана набавка: "..amount.."$", -1)
                end
            end
        end
    end

    if text:find("Ваша зарплата за рейс") then
        isTripActive = false

        local salary = parseMoneyFromServerFormat(text)
        if salary and salary > 0 then
            curSessionMoney = curSessionMoney + salary
            curSessionDeliveries = (curSessionDeliveries or 0) + 1
            lastDeliveryTime = os.time()
        end

        if cbAutoRelog[0] then
            sampAddChatMessage(prefix .. "Рейс окончен. {FFD700}Авто-релог через 5 секунд...", -1)
            settings.isRelogging = true
            saveConfig()
            reconnect(5000)
        end
        return
    end

    if text:find("Вы получили транспорт на базе") then
        currentTripStart = os.time()
        isTripActive = true
    end

    if text:find("Вы получили предмет") and text:find("Откройте инвентарь") then
        local foundBoxKey = nil

        if text:find(":item9770:") or text:find(":item9769:") then
            if os.time() - lastDeliveryTime <= 5 then
                curSessionDividends = curSessionDividends + 1
                sessionDividendMoneyEarned = sessionDividendMoneyEarned + settings.dividendPrice
            end
        end

        for _, box in ipairs(lootboxList) do
            if text:find(box.id) then
                foundBoxKey = box.key
                break
            end
        end

        if foundBoxKey then
            if os.time() - lastDeliveryTime <= 5 then
                curSessionLootboxes = curSessionLootboxes + 1
                local price = settings.lootPrices[foundBoxKey] or 0
                sessionLootMoneyEarned = (sessionLootMoneyEarned or 0) + price
            end
        end
    end
end
Скрипт все еще очень крутой, как хелпер но требует переработки
Авто-открытие ворот больше не требуется, сервер сам открывает (Не уверен)
Авто-спорт кривая реализация
Аренду с оптимусом вроде как не пофиксил
Подсчет ларцов/дивидентов - требуется переработка, тк ларцы сейчас поступают в хранилище, а дивиденты после получения первого в инвентарь, в чате не отображаются
Кривой авто-релог, даёт банчик ип

За крутую базу для читиков однозначно лайкец <3
Пока не планирую обновлять скрипт, с Оптимусом у меня было все нормально, я хз как ты ловил краш.
 

Mario77

Новичок
5
0
Добавить:
parse:
function parseMoneyFromServerFormat(text)
    local total = 0
    local m = text:match(":M:%s*(%d+)")
    if m then total = total + tonumber(m) * 1000000000 end
    local kk = text:match(":KK:%s*(%d+)")
    if kk then total = total + tonumber(kk) * 1000000 end
    local k = text:match(":K:%s*([%d%.]+)")
    if k then
        local clean_k = k:gsub("%.", "")
        total = total + tonumber(clean_k)
    end
    return total
end

Заменить:
se.onServerMessage:
function se.onServerMessage(color, text)
    if not isSessionActive then return end

    if settings.custom and settings.custom.triggers then
        for _, trigger in ipairs(settings.custom.triggers) do
            local safePattern = trigger.text:gsub("([%(%)%.%%%+%-%*%?%[%^%$])", "%%%1")
            safePattern = safePattern:gsub("{СУММА}", "(%%d+)")
            safePattern = safePattern:gsub("{ЧИСЛО}", "(%%d+)")

            if text:find(safePattern) then
                local amount = text:match(safePattern)
                if amount then
                    curSessionMoney = curSessionMoney + tonumber(amount)
                    sampAddChatMessage(prefix.."Поймана набавка: "..amount.."$", -1)
                end
            end
        end
    end

    if text:find("Ваша зарплата за рейс") then
        isTripActive = false

        local salary = parseMoneyFromServerFormat(text)
        if salary and salary > 0 then
            curSessionMoney = curSessionMoney + salary
            curSessionDeliveries = (curSessionDeliveries or 0) + 1
            lastDeliveryTime = os.time()
        end

        if cbAutoRelog[0] then
            sampAddChatMessage(prefix .. "Рейс окончен. {FFD700}Авто-релог через 5 секунд...", -1)
            settings.isRelogging = true
            saveConfig()
            reconnect(5000)
        end
        return
    end

    if text:find("Вы получили транспорт на базе") then
        currentTripStart = os.time()
        isTripActive = true
    end

    if text:find("Вы получили предмет") and text:find("Откройте инвентарь") then
        local foundBoxKey = nil

        if text:find(":item9770:") or text:find(":item9769:") then
            if os.time() - lastDeliveryTime <= 5 then
                curSessionDividends = curSessionDividends + 1
                sessionDividendMoneyEarned = sessionDividendMoneyEarned + settings.dividendPrice
            end
        end

        for _, box in ipairs(lootboxList) do
            if text:find(box.id) then
                foundBoxKey = box.key
                break
            end
        end

        if foundBoxKey then
            if os.time() - lastDeliveryTime <= 5 then
                curSessionLootboxes = curSessionLootboxes + 1
                local price = settings.lootPrices[foundBoxKey] or 0
                sessionLootMoneyEarned = (sessionLootMoneyEarned or 0) + price
            end
        end
    end
end
Скрипт все еще очень крутой, как хелпер но требует переработки
Авто-открытие ворот больше не требуется, сервер сам открывает (Не уверен)
Авто-спорт кривая реализация
Аренду с оптимусом вроде как не пофиксил
Подсчет ларцов/дивидентов - требуется переработка, тк ларцы сейчас поступают в хранилище, а дивиденты после получения первого в инвентарь, в чате не отображаются
Кривой авто-релог, даёт банчик ип

За крутую базу для читиков однозначно лайкец <3
А куда добавить?