Помогите с onShowDialog

Unknown.command

Известный
Автор темы
38
7
Версия MoonLoader
.027.0-preview
Я пытаюсь отловить текст в одном диалоге, при этом через onShowDialog() проходят все диалоги вообще в игре. Помогите исправить


lua:
require('lib.sampfuncs')
local SE = require('samp.events')

function main()
    repeat wait(0) until isSampAvailable()
    while true do wait(0)
        if isKeyJustPressed(0x4C) and not sampIsChatInputActive() and not sampIsDialogActive() then carload() end
    end
end

function carload()
    status = false
    sampSendChat("/cars")
    sampSendDialogResponse(162,1,0,nil)
    function SE.onShowDialog(dialogid, style, title, button1, button2, text)
        sampAddChatMessage(text,-1)
        if text:find("Загрузить") then sampSendDialogResponse(163,1,0,nil) status = true end
        if text:find("Закрыть") or text:find("Открыть") then sampSendDialogResponse(163,1,11,nil) status = false end
        return false
    end
    if status then sampAddChatMessage("{6FA8DC}[CarLoad] {FFFFFF}Авто загружено в мир!",-1)
    else sampAddChatMessage("{6FA8DC}[CarLoad] {FFFFFF}Авто выгружено!",-1) end
end
 

PanSeek

t.me/dailypanseek
Всефорумный модератор
899
1,744
?
Lua:
local se = require 'samp.events'

local active = false

function main()
    repeat wait(0) until isSampAvailable()
    while true do
        wait(0)
        if isKeyJustPressed(0x4C) and not sampIsChatInputActive() and not sampIsDialogActive() then
            carload()
        end
    end
end

function carload()
    active = false
    sampSendChat("/cars")
    sampSendDialogResponse(162, 1, 0, nil)
    sampAddChatMessage(active and "{6FA8DC}[CarLoad] {FFFFFF}Авто загружено в мир!" or "{6FA8DC}[CarLoad] {FFFFFF}Авто выгружено!", -1)
end

function se.onShowDialog(dialogid, style, title, button1, button2, text)
    if active then
        if text:find("Загрузить") then
            sampSendDialogResponse(163, 1, 0, nil)
            status = true
        end
        if text:find("Закрыть") or text:find("Открыть") then
            sampSendDialogResponse(163, 1, 11, nil)
            status = false
        end
        return false
    end
end
Но смысл status нет уже.
 

Unknown.command

Известный
Автор темы
38
7
?
Lua:
local se = require 'samp.events'

local active = false

function main()
    repeat wait(0) until isSampAvailable()
    while true do
        wait(0)
        if isKeyJustPressed(0x4C) and not sampIsChatInputActive() and not sampIsDialogActive() then
            carload()
        end
    end
end

function carload()
    active = false
    sampSendChat("/cars")
    sampSendDialogResponse(162, 1, 0, nil)
    sampAddChatMessage(active and "{6FA8DC}[CarLoad] {FFFFFF}Авто загружено в мир!" or "{6FA8DC}[CarLoad] {FFFFFF}Авто выгружено!", -1)
end

function se.onShowDialog(dialogid, style, title, button1, button2, text)
    if active then
        if text:find("Загрузить") then
            sampSendDialogResponse(163, 1, 0, nil)
            status = true
        end
        if text:find("Закрыть") or text:find("Открыть") then
            sampSendDialogResponse(163, 1, 11, nil)
            status = false
        end
        return false
    end
end
Но смысл status нет уже.
Active никогда не меняется, следовательно кусок кода, который принимает диалог не выполнится энивей