Возможность скрипта самостоятельно выбирать действие в диалоге.

Kun_Vays

Новичок
Автор темы
19
0
Версия MoonLoader
.027.0-preview
Здравствуйте, народ. Снова обращаюсь к вам!
Хочу сделать, чтобы скрипт мог сам заходить в диалог (то-бишь писать команду) и нажимать в нем определенные пункты.
Видел подобное в МедикалХелпере для Аризоны, но у меня скопировать оттуда не получаеться. :(

Прошу помощи у вас. :)
имеющийся код:
function imgui.OnDrawFrame()
    if main_window_state.v then
        imgui.SetNextWindowSize(imgui.ImVec2(500, 500), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos(imgui.ImVec2(resX / 2, resY / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.Begin("Truck Helper. by Kun_Vays", main_window_state, imgui.WindowFlags.NoResize)
        imgui.Text("абв|abc")
        imgui.InputText("пиши сюда", text_buffer)
        imgui.Text(text_buffer.v)
            if imgui.Button("Press me") then
            printStringNow("pressed", 2000)
            sampAddChatMessage(tag .. "{DA70D6} You pressed button!", 0xDA70D6)
            sampAddChatMessage(tag .. "{DA70D6} You wrote: {00BFFF}" .. text_buffer.v, 0xDA70D6)
            sampSendChat("/cars")
            repeat wait(100) until sampIsDialogActive() and sampGetCurrentDialogId() == 162
            sampSetCurrentDialogListItem(2)
            wait(300)
            sampCloseCurrentDialogWithButton(1)
            repeat wait(100) until sampIsDialogActive() and sampGetCurrentDialogId() == 163
            sampSetCurrentDialogListItem(0)
            wait(100)
            sampCloseCurrentDialogWithButton(1)
            repeat wait(0) until sampIsDialogActive() and sampGetCurrentDialogId() == 1335
            wait(350)
            sampSetCurrentDialogEditboxText(inpSob)
            wait(350)
            sampCloseCurrentDialogWithButton(1)
            wait(1700) 
            end
        imgui.End()
    end
    



end


function onWindowMessage(msg, wparam, lparam)
    if msg == 0x100 or msg == 0x101 then
        if (wparam == key.VK_ESCAPE and main_window_state.v) and not isPauseMenuActive() then
            consumeWindowMessage(true, false)
            if msg == 0x101 then
                main_window_state.v = false
            end
        end
    end
end
 
Решение
Lua:
local on = require('lib.samp.events')
function on.onShowDialog(did, style, title, b1, b2, text)
    if did == 69 then
        sampSendDialogResponse(--[[Здесь ид диалога]] did, --[[Здесь кнопку которая будет нажиматься левая - 1 | правая - 0]] 1, --[[здесь лист из DIALOG_STYLE_LIST]] _, 'Сюда текст для input диалогов, если не input диалог то ставь _ заместо текста')
    end
end

ARMOR

kjor32 is legend
Модератор
4,851
6,081
Здравствуйте, народ. Снова обращаюсь к вам!
Хочу сделать, чтобы скрипт мог сам заходить в диалог (то-бишь писать команду) и нажимать в нем определенные пункты.
Видел подобное в МедикалХелпере для Аризоны, но у меня скопировать оттуда не получаеться. :(

Прошу помощи у вас. :)
имеющийся код:
function imgui.OnDrawFrame()
    if main_window_state.v then
        imgui.SetNextWindowSize(imgui.ImVec2(500, 500), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos(imgui.ImVec2(resX / 2, resY / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.Begin("Truck Helper. by Kun_Vays", main_window_state, imgui.WindowFlags.NoResize)
        imgui.Text("абв|abc")
        imgui.InputText("пиши сюда", text_buffer)
        imgui.Text(text_buffer.v)
            if imgui.Button("Press me") then
            printStringNow("pressed", 2000)
            sampAddChatMessage(tag .. "{DA70D6} You pressed button!", 0xDA70D6)
            sampAddChatMessage(tag .. "{DA70D6} You wrote: {00BFFF}" .. text_buffer.v, 0xDA70D6)
            sampSendChat("/cars")
            repeat wait(100) until sampIsDialogActive() and sampGetCurrentDialogId() == 162
            sampSetCurrentDialogListItem(2)
            wait(300)
            sampCloseCurrentDialogWithButton(1)
            repeat wait(100) until sampIsDialogActive() and sampGetCurrentDialogId() == 163
            sampSetCurrentDialogListItem(0)
            wait(100)
            sampCloseCurrentDialogWithButton(1)
            repeat wait(0) until sampIsDialogActive() and sampGetCurrentDialogId() == 1335
            wait(350)
            sampSetCurrentDialogEditboxText(inpSob)
            wait(350)
            sampCloseCurrentDialogWithButton(1)
            wait(1700)
            end
        imgui.End()
    end
   



end


function onWindowMessage(msg, wparam, lparam)
    if msg == 0x100 or msg == 0x101 then
        if (wparam == key.VK_ESCAPE and main_window_state.v) and not isPauseMenuActive() then
            consumeWindowMessage(true, false)
            if msg == 0x101 then
                main_window_state.v = false
            end
        end
    end
end
Юзай sampSendDialogResponse()
 

sat0ry

Известный
1,089
290

qdIbp

Автор темы
Проверенный
1,386
1,141
Lua:
local on = require('lib.samp.events')
function on.onShowDialog(did, style, title, b1, b2, text)
    if did == 69 then
        sampSendDialogResponse(--[[Здесь ид диалога]] did, --[[Здесь кнопку которая будет нажиматься левая - 1 | правая - 0]] 1, --[[здесь лист из DIALOG_STYLE_LIST]] _, 'Сюда текст для input диалогов, если не input диалог то ставь _ заместо текста')
    end
end
 

qdIbp

Автор темы
Проверенный
1,386
1,141
Можно без onShowDialog
Lua:
sampSendDialogResponse(69, 1, _, 'text')

Индентично, но у тебя через библиотеку и ид диалога. К тому же, я не советовал бы печатать код за других, ибо будут копипастеры да и все.
Это пример использование :\
 

ARMOR

kjor32 is legend
Модератор
4,851
6,081
Lua:
local on = require('lib.samp.events')
function on.onShowDialog(did, style, title, b1, b2, text)
    if did == 69 then
        sampSendDialogResponse(--[[Здесь ид диалога]] did, --[[Здесь кнопку которая будет нажиматься левая - 1 | правая - 0]] 1, --[[здесь лист из DIALOG_STYLE_LIST]] _, 'Сюда текст для input диалогов, если не input диалог то ставь _ заместо текста')
    end
end
Как по мне так лучше nil вместо _ ставить
 

Kun_Vays

Новичок
Автор темы
19
0
123:
function on.onShowDialog(did, style, title, b1, b2, text)
    if did == 69 then
        sampSendDialogResponse(162, did, 1, 1, DIALOG_STYLE_LIST, _)
    end
end
что то такое должно быть?
Lua:
local on = require('lib.samp.events')
function on.onShowDialog(did, style, title, b1, b2, text)
    if did == 69 then
        sampSendDialogResponse(--[[Здесь ид диалога]] did, --[[Здесь кнопку которая будет нажиматься левая - 1 | правая - 0]] 1, --[[здесь лист из DIALOG_STYLE_LIST]] _, 'Сюда текст для input диалогов, если не input диалог то ставь _ заместо текста')
    end
end
 

Kun_Vays

Новичок
Автор темы
19
0
Lua:
local ev = require 'lib.samp.events'

function ev.onShowDialog(did, style, title, b1, b2, text)
    if did == 69 then
        sampSendDialogResponse(did, 1, 1, nil)
    end
end
1:
[ML] (error) trucker.lua: E:\ARIZONA GAMES\bin\Arizona\moonloader\trucker.lua:99: 'end' expected (to close 'function' at line 59) near '<eof>'
[ML] (error) trucker.lua: Script died due to an error. (116DAB14)
мб я не туда вставил?

123:
function imgui.OnDrawFrame()
    if main_window_state.v then
        imgui.SetNextWindowSize(imgui.ImVec2(500, 500), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos(imgui.ImVec2(resX / 2, resY / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.Begin("Truck Helper. by Kun_Vays", main_window_state, imgui.WindowFlags.NoResize)
        imgui.Text("абв|abc")
        imgui.InputText("пиши сюда", text_buffer)
        imgui.Text(text_buffer.v)
            if imgui.Button("Press me") then
            printStringNow("pressed", 2000)
            sampAddChatMessage(tag .. "{DA70D6} You pressed button!", 0xDA70D6)
            sampAddChatMessage(tag .. "{DA70D6} You wrote: {00BFFF}" .. text_buffer.v, 0xDA70D6)
            sampSendChat("/cars")
            function ev.onShowDialog(did, style, title, b1, b2, text)
                if did == 69 then
                    sampSendDialogResponse(did, 1, 1, nil)
                end
            end
        imgui.End()
    end
    



end
 

ARMOR

kjor32 is legend
Модератор
4,851
6,081
1:
[ML] (error) trucker.lua: E:\ARIZONA GAMES\bin\Arizona\moonloader\trucker.lua:99: 'end' expected (to close 'function' at line 59) near '<eof>'
[ML] (error) trucker.lua: Script died due to an error. (116DAB14)
мб я не туда вставил?

123:
function imgui.OnDrawFrame()
    if main_window_state.v then
        imgui.SetNextWindowSize(imgui.ImVec2(500, 500), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos(imgui.ImVec2(resX / 2, resY / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.Begin("Truck Helper. by Kun_Vays", main_window_state, imgui.WindowFlags.NoResize)
        imgui.Text("абв|abc")
        imgui.InputText("пиши сюда", text_buffer)
        imgui.Text(text_buffer.v)
            if imgui.Button("Press me") then
            printStringNow("pressed", 2000)
            sampAddChatMessage(tag .. "{DA70D6} You pressed button!", 0xDA70D6)
            sampAddChatMessage(tag .. "{DA70D6} You wrote: {00BFFF}" .. text_buffer.v, 0xDA70D6)
            sampSendChat("/cars")
            function ev.onShowDialog(did, style, title, b1, b2, text)
                if did == 69 then
                    sampSendDialogResponse(did, 1, 1, nil)
                end
            end
        imgui.End()
    end
   



end
Да, не туда. Оно должно быть как отдельная функция, за function imgui.OnDrawFrame()
 

qdIbp

Автор темы
Проверенный
1,386
1,141
Код:
function imgui.OnDrawFrame()
    if main_window_state.v then
        imgui.SetNextWindowSize(imgui.ImVec2(500, 500), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos(imgui.ImVec2(resX / 2, resY / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.Begin("Truck Helper. by Kun_Vays", main_window_state, imgui.WindowFlags.NoResize)
        imgui.Text("абв|abc")
        imgui.InputText("пиши сюда", text_buffer)
        imgui.Text(text_buffer.v)
            if imgui.Button("Press me") then
            printStringNow("pressed", 2000)
            sampAddChatMessage(tag .. "{DA70D6} You pressed button!", 0xDA70D6)
            sampAddChatMessage(tag .. "{DA70D6} You wrote: {00BFFF}" .. text_buffer.v, 0xDA70D6)
            sampSendChat("/cars")
                sampSendDialogResponse(69, 1, 1, nil)
        imgui.End()
    end
end

69 это id диалога а у всех диалогов они разные, чтобы узнать ид диалога который тебе нужена функция
Либо обращаться
Lua:
local on = require 'lib.samp.events'
function on.onShowDialog(did, style, title, b1, b2, text)
    print(did)
end

Lua:
sampSendDialogResponse[/I](sampGetCurrentDialogId(),1,1,_)
 
Последнее редактирование: