Как сделать чат диалог самп чтобы можно было в него ввести текст

leekyrave

Известный
418
226
Lua:
-- main for example
sampShowDialog(6406, "Ввод текста", "Я еду в Сочи, кто рад пишите плюс", "ОК", "Отмена", DIALOG_STYLE_INPUT)
while sampIsDialogActive(6406) do wait(100) end
local result, button, _, input = sampHasDialogRespond(6406)
 

Yakov Inc.

Участник
Автор темы
89
6
Lua:
-- main for example
sampShowDialog(6406, "Ввод текста", "Я еду в Сочи, кто рад пишите плюс", "ОК", "Отмена", DIALOG_STYLE_INPUT)
while sampIsDialogActive(6406) do wait(100) end
local result, button, _, input = sampHasDialogRespond(6406)
Как его вставить к этому коду?

function main()
sampRegisterChatCommand('test', function()
sampAddChatMessage('Text', -1)
end)
wait(-1)
end
 

Rice.

Известный
Модератор
1,753
1,660
Как его вставить к этому коду?

function main()
sampRegisterChatCommand('test', function()
sampAddChatMessage('Text', -1)
end)
wait(-1)
end

Lua:
require "lib.moonloader"

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
    
    sampRegisterChatCommand("dialog", cmd_dialog)
    
    while true do
        wait(0)
        
        local result, button, list, input = sampHasDialogRespond(11) -- /dialog1 (InputBox)

        if result then -- если диалог открыт
            if button == 1 then -- если нажата первая кнопка (Выбрать)
                sampAddChatMessage("Вы нажали кнопку выбора в диалоге с ID 11, и ввели туда: {FFFFFF}" .. input, -1)
            else -- если нажата вторая кнопка (Закрыть)
                sampAddChatMessage("Вы закрыли диалог с ID 11", -1)
            end
        end
        
    end
end

function dialog(arg)
    sampShowDialog(11, "Диалог с типом ID 1 (InputBox)", "Введите какую-либо строку", "Выбрать", "Закрыть", 1)
end

Больше:
 

Yakov Inc.

Участник
Автор темы
89
6
Lua:
require "lib.moonloader"

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
   
    sampRegisterChatCommand("dialog", cmd_dialog)
   
    while true do
        wait(0)
       
        local result, button, list, input = sampHasDialogRespond(11) -- /dialog1 (InputBox)

        if result then -- если диалог открыт
            if button == 1 then -- если нажата первая кнопка (Выбрать)
                sampAddChatMessage("Вы нажали кнопку выбора в диалоге с ID 11, и ввели туда: {FFFFFF}" .. input, -1)
            else -- если нажата вторая кнопка (Закрыть)
                sampAddChatMessage("Вы закрыли диалог с ID 11", -1)
            end
        end
       
    end
end

function dialog(arg)
    sampShowDialog(11, "Диалог с типом ID 1 (InputBox)", "Введите какую-либо строку", "Выбрать", "Закрыть", 1)
end

Больше:
Крашит скрипт
 

F0RQU1N and

Известный
1,301
498