помогите с диалогом lua

TheMatteo

Участник
Автор темы
34
4
Версия MoonLoader
Другое
нужно чтобы в диалоге выбирал последний пункт - частный самолет и нажимал энтер


Код:
Current dialog info:
Dialog ID: 1421
Dialog Type: 5
Dialog Caption:
Выберите самолет
Dialog text:
Самолеты в аэропорту:
[AIRLV-1] Shamal
[AIRLV-2] Shamal
[AIRLV-3] Shamal
[AIRLV-4] Shamal
[AIRLV-5] Nevada
[AIRLV-6] Nevada
[AIRLV-7] Andromada
[AIRLV-8] Andromada
[AIRLV-9] AT400
Частный самолет
 
Решение
Lua:
local SampEvents = require("samp.events");

function SampEvents.onShowDialog(dialogId, style, title, button1, button2, text)
    if (title:find("Самолеты в аэро")) then
        local lineIndex = -1;
        for line in text:gmatch("[^\n]+") do
            lineIndex = lineIndex + 1;
            if (line:find("Частный")) then
                sampSendDialogResponse(dialogId, 1, lineIndex, nil);
                return false;
            end
        end
    end
end

TheMatteo

Участник
Автор темы
34
4
Lua:
local events = require "samp.events"

function events.onShowDialog(dialogId, style, title, button1, button2, text)
    if dialogId == 1421 then
        sampSendDialogResponse(1421, 1, 9, "")
        return false
    end
end

function main()
    repeat wait(0) until isSampAvailable()
    while true do
        wait(0)
    end
end
1761264497808.png
ставлю 9, но выбирает почему-то другой самолет
 

chapo

tg/inst: @moujeek
Всефорумный модератор
9,205
12,525
Lua:
local SampEvents = require("samp.events");

function SampEvents.onShowDialog(dialogId, style, title, button1, button2, text)
    if (title:find("Самолеты в аэро")) then
        local lineIndex = -1;
        for line in text:gmatch("[^\n]+") do
            lineIndex = lineIndex + 1;
            if (line:find("Частный")) then
                sampSendDialogResponse(dialogId, 1, lineIndex, nil);
                return false;
            end
        end
    end
end
 
  • Нравится
Реакции: TheMatteo и qdIbp