Закрытие диалога

-legacy.

Участник
Автор темы
32
12
Версия MoonLoader
.026-beta
Привку есть вот скрипт на снятие бтк с домов , вот когда снялась все прибыль с домов надо закрытие диалог 7238 ( флешка майнера ) ,


по идеи (нет,гамно способ)

Код:
function sampev.onShowDialog(id, style, title, button1, button2, text)

    if id == 7238 and title:find("Выбор дома") and not active and not withdrawActive and not awaitingFinalProfit then

        sampSendDialogResponse(id, 0, 0, "")

        return true

    end

должен бы закрывать диалог чего не происходит,он просто обржается, аесли нажать на ентер то он пропадает , надо как - то фикс.

Надеюсь норм объяснил )

Lua:
script_author('legacy.')
script_version("1.04")

local sampev = require("samp.events")
local active = false
local houseIndex = 0
local houseCount = 0
local withdrawActive = false
local totalBTC = 0
local totalASC = 0
local awaitingFinalProfit = false

function main()
    repeat wait(0) until isSampAvailable()
    sampAddChatMessage("{C285FF}[Fast Videocard]{FFFFFF} Загружен | Активация: {C285FF}/bitc{FFFFFF}", -1)
    sampRegisterChatCommand('bitc', function()
        active = true
        houseIndex = 0
        withdrawActive = false
        totalBTC = 0
        totalASC = 0
        awaitingFinalProfit = false
        sampSendChat("/flashminer")
    end)
    while true do wait(0) end
end

function sampev.onShowDialog(id, style, title, button1, button2, text)
    if id == 7238 and title:find("Выбор дома") and not active and not withdrawActive and not awaitingFinalProfit then
        sampSendDialogResponse(id, 0, 0, "")
        return true
    end

    if active then
        if id == 7238 and title:find("Выбор дома") then
            local lines = {}
            for line in text:gmatch("[^\r\n]+") do table.insert(lines, line) end
            houseCount = #lines - 1
            if houseCount > 0 then
                sampSendDialogResponse(id, 1, houseIndex, "")
                withdrawActive = true
                houseIndex = houseIndex + 1
                if houseIndex >= houseCount then
                    active = false
                    awaitingFinalProfit = true
                end
            else
                active = false
            end
            return true
        end
    end

    if withdrawActive then
        local function findLineAndRespond(pattern, checkFunc, listboxId)
            for line in text:gmatch("[^\r\n]+") do
                if line:find(pattern) and checkFunc(line) then
                    sampSendDialogResponse(id, 1, listboxId, line)
                    return true
                end
                listboxId = listboxId + 1
            end
            return false
        end

        if title:find('Выберите видеокарту') then
            if not text:find('%d+%.%d%d%d%d%d%d') then
                withdrawActive = false
                if not active and awaitingFinalProfit then showFinalProfit() end
                sampSendDialogResponse(id, 0, 0, "")
                return true
            end
            if not findLineAndRespond('%d+%.%d%d%d%d%d%d', function(line) return tonumber(line:match("(%d+)%.%d%d%d%d%d%d")) > 0 end, -1) then
                withdrawActive = false
                if not active and awaitingFinalProfit then showFinalProfit() end
                sampSendDialogResponse(id, 0, 0, "")
            end
            return true
        elseif title:find('Стойка') then
            if not findLineAndRespond('%d+%.%d%d%d%d%d%d', function(line) return tonumber(line:match("(%d+)%.%d%d%d%d%d%d")) > 0 end, 0) then
                sampSendDialogResponse(id, 0, 0, "")
            end
            return true
        elseif title:find('Вывод прибыли видеокарты') then
            sampSendDialogResponse(id, 1, 0, "")
            return true
        elseif title:find("Информация о видеокарте") or title:find("Прибыль успешно выведена") then
            sampSendDialogResponse(id, 0, 0, "")
            withdrawActive = false
            if not active and awaitingFinalProfit then showFinalProfit() end
            return true
        end
    end
    return true
end

function sampev.onServerMessage(color, text)
    local btcAmount = text:match("Вы вывели {ffffff}(%d+)%sBTC")
    local ascAmount = text:match("Вы вывели {ffffff}(%d+)%sASC")
    local itemBTC = text:match("Вам был добавлен предмет 'Bitcoin %(BTC%)'")
    local itemASC = text:match("Вам был добавлен предмет 'Arizona Coin %(ASC%)'")

    if text:find("В этом доме нет подвала с вентиляцией или он еще не достроен") then
        if houseIndex < houseCount then sampSendChat("/flashminer") else active = false awaitingFinalProfit = true showFinalProfit() end
        return false
    end

    if btcAmount then totalBTC = totalBTC + tonumber(btcAmount) end
    if ascAmount then totalASC = totalASC + tonumber(ascAmount) end
    if itemBTC then totalBTC = totalBTC + 1 end
    if itemASC then totalASC = totalASC + 1 end
end

function showFinalProfit()
    awaitingFinalProfit = false
    sampAddChatMessage(string.format('{C285FF}[Fast Videocard]{FFFFFF} Сбор завершён! Суммарно: {00BFFF}%d BTC{FFFFFF}, {DAA520}%d ASC', totalBTC, totalASC))
end
 

Haru Urara

Участник
52
19
Привку есть вот скрипт на снятие бтк с домов , вот когда снялась все прибыль с домов надо закрытие диалог 7238 ( флешка майнера ) ,


по идеи (нет,гамно способ)

Код:
function sampev.onShowDialog(id, style, title, button1, button2, text)

    if id == 7238 and title:find("Выбор дома") and not active and not withdrawActive and not awaitingFinalProfit then

        sampSendDialogResponse(id, 0, 0, "")

        return true

    end

должен бы закрывать диалог чего не происходит,он просто обржается, аесли нажать на ентер то он пропадает , надо как - то фикс.

Надеюсь норм объяснил )

Lua:
script_author('legacy.')
script_version("1.04")

local sampev = require("samp.events")
local active = false
local houseIndex = 0
local houseCount = 0
local withdrawActive = false
local totalBTC = 0
local totalASC = 0
local awaitingFinalProfit = false

function main()
    repeat wait(0) until isSampAvailable()
    sampAddChatMessage("{C285FF}[Fast Videocard]{FFFFFF} Загружен | Активация: {C285FF}/bitc{FFFFFF}", -1)
    sampRegisterChatCommand('bitc', function()
        active = true
        houseIndex = 0
        withdrawActive = false
        totalBTC = 0
        totalASC = 0
        awaitingFinalProfit = false
        sampSendChat("/flashminer")
    end)
    while true do wait(0) end
end

function sampev.onShowDialog(id, style, title, button1, button2, text)
    if id == 7238 and title:find("Выбор дома") and not active and not withdrawActive and not awaitingFinalProfit then
        sampSendDialogResponse(id, 0, 0, "")
        return true
    end

    if active then
        if id == 7238 and title:find("Выбор дома") then
            local lines = {}
            for line in text:gmatch("[^\r\n]+") do table.insert(lines, line) end
            houseCount = #lines - 1
            if houseCount > 0 then
                sampSendDialogResponse(id, 1, houseIndex, "")
                withdrawActive = true
                houseIndex = houseIndex + 1
                if houseIndex >= houseCount then
                    active = false
                    awaitingFinalProfit = true
                end
            else
                active = false
            end
            return true
        end
    end

    if withdrawActive then
        local function findLineAndRespond(pattern, checkFunc, listboxId)
            for line in text:gmatch("[^\r\n]+") do
                if line:find(pattern) and checkFunc(line) then
                    sampSendDialogResponse(id, 1, listboxId, line)
                    return true
                end
                listboxId = listboxId + 1
            end
            return false
        end

        if title:find('Выберите видеокарту') then
            if not text:find('%d+%.%d%d%d%d%d%d') then
                withdrawActive = false
                if not active and awaitingFinalProfit then showFinalProfit() end
                sampSendDialogResponse(id, 0, 0, "")
                return true
            end
            if not findLineAndRespond('%d+%.%d%d%d%d%d%d', function(line) return tonumber(line:match("(%d+)%.%d%d%d%d%d%d")) > 0 end, -1) then
                withdrawActive = false
                if not active and awaitingFinalProfit then showFinalProfit() end
                sampSendDialogResponse(id, 0, 0, "")
            end
            return true
        elseif title:find('Стойка') then
            if not findLineAndRespond('%d+%.%d%d%d%d%d%d', function(line) return tonumber(line:match("(%d+)%.%d%d%d%d%d%d")) > 0 end, 0) then
                sampSendDialogResponse(id, 0, 0, "")
            end
            return true
        elseif title:find('Вывод прибыли видеокарты') then
            sampSendDialogResponse(id, 1, 0, "")
            return true
        elseif title:find("Информация о видеокарте") or title:find("Прибыль успешно выведена") then
            sampSendDialogResponse(id, 0, 0, "")
            withdrawActive = false
            if not active and awaitingFinalProfit then showFinalProfit() end
            return true
        end
    end
    return true
end

function sampev.onServerMessage(color, text)
    local btcAmount = text:match("Вы вывели {ffffff}(%d+)%sBTC")
    local ascAmount = text:match("Вы вывели {ffffff}(%d+)%sASC")
    local itemBTC = text:match("Вам был добавлен предмет 'Bitcoin %(BTC%)'")
    local itemASC = text:match("Вам был добавлен предмет 'Arizona Coin %(ASC%)'")

    if text:find("В этом доме нет подвала с вентиляцией или он еще не достроен") then
        if houseIndex < houseCount then sampSendChat("/flashminer") else active = false awaitingFinalProfit = true showFinalProfit() end
        return false
    end

    if btcAmount then totalBTC = totalBTC + tonumber(btcAmount) end
    if ascAmount then totalASC = totalASC + tonumber(ascAmount) end
    if itemBTC then totalBTC = totalBTC + 1 end
    if itemASC then totalASC = totalASC + 1 end
end

function showFinalProfit()
    awaitingFinalProfit = false
    sampAddChatMessage(string.format('{C285FF}[Fast Videocard]{FFFFFF} Сбор завершён! Суммарно: {00BFFF}%d BTC{FFFFFF}, {DAA520}%d ASC', totalBTC, totalASC))
end
Попробуй использовать либо
Lua:
function sampev.onShowDialog(id, style, title, button1, button2, text)
    if id == 7238 and title:find("Выбор дома") and not active and not withdrawActive and not awaitingFinalProfit then
        sampSendDialogResponse(id, 0, 0, "")
        return false -- блокирует открытие
    end
end
или
Lua:
function sampev.onShowDialog(id, style, title, button1, button2, text)
    if id == 7238 and title:find("Выбор дома") and not active and not withdrawActive and not awaitingFinalProfit then
        lua_thread.create(function()
            wait(50) -- время в мс (50 = 0.05с)
            sampSendDialogResponse(id, 0, 0, "")
        end)
        return false
    end
end
 
Последнее редактирование: