sampSendDialogResponse

Yelawolf

Участник
Автор темы
14
3
Версия MoonLoader
.026-beta
Lua:
require "lib.moonloader"
local ev = require "lib.samp.events"
local se = require "lib.samp.events"
local vkeys = require "vkeys"

actions = 0

function main()
    while true do
        wait(0)

        if isKeyJustPressed(0x69) then
        actions = 1
        sampSendChat("/invex")
        end
        if isKeyJustPressed(0x68) then
        actions = 2
        sampSendChat("/invex")
        end
        if isKeyJustPressed(0x67) then
        actions = 3
        sampSendChat("/invex")
        end
        if isKeyJustPressed(0x60) then
        actions = 4
        sampSendChat("/invex")
        end
        if isKeyJustPressed(0x61) then
        actions = 5
        sampSendChat("/pot")
        end
        if isKeyJustPressed(0x62) then
        actions = 6
        sampSendChat("/pot")
        end
        if isKeyJustPressed(0x63) then
        actions = 7
        sampSendChat("/pot")
        end
        if isKeyJustPressed(0x64) then
        actions = 8
        sampSendChat("/pot")
        end
        if isKeyJustPressed(0x65) then
        actions = 9
        sampSendChat("/pot")
        end


        function ev.onShowDialog(id, st, tit, b1, b2, tx)
            lua_thread.create(function()
                count = 0
                if actions == 1 then
                    for line in tx:gmatch("[^\n\r]+") do
                        if line:find("Пакет минеральных удобрений") then
                            wait(1000)
                            sampSendDialogResponse(1000, 1, count, "")
                            wait(1000)
                            sampSendDialogResponse(1001, 1, 5, "")
                            wait(1000)
                            sampCloseCurrentDialogWithButton(0)
                            actions = 0
                        end
                        count = count + 1
                    end
                end
                count = 0
                if actions == 2 then
                    for line in tx:gmatch("[^\n\r]+") do
                        if line:find("Тяпка") then
                            wait(1000)
                            sampSendDialogResponse(1000, 1, count, "")
                            wait(1000)
                            sampSendDialogResponse(1001, 1, 5, "")
                            wait(1000)
                            sampCloseCurrentDialogWithButton(0)
                            actions = 0
                        end
                        count = count + 1
                    end
                end
                count = 0
                if actions == 3 then
                    for line in tx:gmatch("[^\n\r]+") do
                        if line:find("Ведро с водой") then
                            wait(1000)
                            sampSendDialogResponse(1000, 1, count, "")
                            wait(1000)
                            sampSendDialogResponse(1001, 1, 5, "")
                            wait(1000)
                            sampCloseCurrentDialogWithButton(0)
                            actions = 0
                        end
                        count = count + 1
                    end
                end
                count = 0
                if actions == 4 then
                    for line in tx:gmatch("[^\n\r]+") do
                        if line:find("Пакетик семян") then
                            wait(1000)
                            sampSendDialogResponse(1000, 1, count, "")
                            wait(1000)
                            sampSendDialogResponse(1001, 1, 5, "")
                            wait(1000)
                            sampCloseCurrentDialogWithButton(0)
                            actions = 0
                        end
                        count = count + 1
                    end
                end
            end)
        end

        function se.onShowTextDraw(id, data)
            if actions == 5 then
                sampSendClickTextdraw(164)
                sampSendClickTextdraw(169)
                actions = 0
            end
            if actions == 6 then
                sampSendClickTextdraw(165)
                sampSendClickTextdraw(169)
                actions = 0
            end
            if actions == 7 then
                sampSendClickTextdraw(166)
                sampSendClickTextdraw(169)
                actions = 0
            end
            if actions == 8 then
                sampSendClickTextdraw(167)
                sampSendClickTextdraw(169)
                actions = 0
            end
            if actions == 9 then
                sampSendClickTextdraw(168)
                sampSendClickTextdraw(169)
                actions = 0
            end
        end
    end
end
У меня какая-то проблема с sampSendDialogResponse. Код выполняется, диалоги прожимаются, НО как только любой код с диалогами выполняется - выкидывает с сервера. Задержки и так нормальные, увеличивал - толку и нет, серовно Server closed the conection. Help.
 

манку хлебал

Потрачен
305
121
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Lua:
require "lib.moonloader"
local ev = require "lib.samp.events"
local se = require "lib.samp.events"
local vkeys = require "vkeys"

actions = 0

function main()
    while true do
        wait(0)
        if isKeyJustPressed(0x69) then
            actions = 1
            sampSendChat("/invex")
        end
        if isKeyJustPressed(0x68) then
            actions = 2
            sampSendChat("/invex")
        end
        if isKeyJustPressed(0x67) then
            actions = 3
            sampSendChat("/invex")
        end
        if isKeyJustPressed(0x60) then
            actions = 4
            sampSendChat("/invex")
        end
        if isKeyJustPressed(0x61) then
            actions = 5
            sampSendChat("/pot")
        end
        if isKeyJustPressed(0x62) then
            actions = 6
            sampSendChat("/pot")
        end
        if isKeyJustPressed(0x63) then
            actions = 7
            sampSendChat("/pot")
        end
        if isKeyJustPressed(0x64) then
            actions = 8
            sampSendChat("/pot")
        end
        if isKeyJustPressed(0x65) then
            actions = 9
            sampSendChat("/pot")
        end
    end
end

function ev.onShowDialog(id, st, tit, b1, b2, tx)
    lua_thread.create(function()
        count = 0
        if actions == 1 then
            for line in tx:gmatch("[^\n\r]+") do
                if line:find("Пакет минеральных удобрений") then
                    wait(1000)
                    sampSendDialogResponse(1000, 1, count, "")
                    wait(1000)
                    sampSendDialogResponse(1001, 1, 5, "")
                    wait(1000)
                    sampCloseCurrentDialogWithButton(0)
                    actions = 0
                end
                count = count + 1
            end
        end
        count = 0
        if actions == 2 then
            for line in tx:gmatch("[^\n\r]+") do
                if line:find("Тяпка") then
                    wait(1000)
                    sampSendDialogResponse(1000, 1, count, "")
                    wait(1000)
                    sampSendDialogResponse(1001, 1, 5, "")
                    wait(1000)
                    sampCloseCurrentDialogWithButton(0)
                    actions = 0
                end
                count = count + 1
            end
        end
        count = 0
        if actions == 3 then
            for line in tx:gmatch("[^\n\r]+") do
                if line:find("Ведро с водой") then
                    wait(1000)
                    sampSendDialogResponse(1000, 1, count, "")
                    wait(1000)
                    sampSendDialogResponse(1001, 1, 5, "")
                    wait(1000)
                    sampCloseCurrentDialogWithButton(0)
                    actions = 0
                end
                count = count + 1
            end
        end
        count = 0
        if actions == 4 then
            for line in tx:gmatch("[^\n\r]+") do
                if line:find("Пакетик семян") then
                    wait(1000)
                    sampSendDialogResponse(1000, 1, count, "")
                    wait(1000)
                    sampSendDialogResponse(1001, 1, 5, "")
                    wait(1000)
                    sampCloseCurrentDialogWithButton(0)
                    actions = 0
                end
                count = count + 1
            end
        end
    end)
end

function se.onShowTextDraw(id, data)
    if actions == 5 then
        sampSendClickTextdraw(164)
        sampSendClickTextdraw(169)
        actions = 0
    end
    if actions == 6 then
        sampSendClickTextdraw(165)
        sampSendClickTextdraw(169)
        actions = 0
    end
    if actions == 7 then
        sampSendClickTextdraw(166)
        sampSendClickTextdraw(169)
        actions = 0
    end
    if actions == 8 then
        sampSendClickTextdraw(167)
        sampSendClickTextdraw(169)
        actions = 0
    end
    if actions == 9 then
        sampSendClickTextdraw(168)
        sampSendClickTextdraw(169)
        actions = 0
    end
end
 
  • Нравится
Реакции: Yelawolf

Yelawolf

Участник
Автор темы
14
3
Lua:
require "lib.moonloader"
local ev = require "lib.samp.events"
local se = require "lib.samp.events"
local vkeys = require "vkeys"

actions = 0

function main()
    while true do
        wait(0)
        if isKeyJustPressed(0x69) then
            actions = 1
            sampSendChat("/invex")
        end
        if isKeyJustPressed(0x68) then
            actions = 2
            sampSendChat("/invex")
        end
        if isKeyJustPressed(0x67) then
            actions = 3
            sampSendChat("/invex")
        end
        if isKeyJustPressed(0x60) then
            actions = 4
            sampSendChat("/invex")
        end
        if isKeyJustPressed(0x61) then
            actions = 5
            sampSendChat("/pot")
        end
        if isKeyJustPressed(0x62) then
            actions = 6
            sampSendChat("/pot")
        end
        if isKeyJustPressed(0x63) then
            actions = 7
            sampSendChat("/pot")
        end
        if isKeyJustPressed(0x64) then
            actions = 8
            sampSendChat("/pot")
        end
        if isKeyJustPressed(0x65) then
            actions = 9
            sampSendChat("/pot")
        end
    end
end

function ev.onShowDialog(id, st, tit, b1, b2, tx)
    lua_thread.create(function()
        count = 0
        if actions == 1 then
            for line in tx:gmatch("[^\n\r]+") do
                if line:find("Пакет минеральных удобрений") then
                    wait(1000)
                    sampSendDialogResponse(1000, 1, count, "")
                    wait(1000)
                    sampSendDialogResponse(1001, 1, 5, "")
                    wait(1000)
                    sampCloseCurrentDialogWithButton(0)
                    actions = 0
                end
                count = count + 1
            end
        end
        count = 0
        if actions == 2 then
            for line in tx:gmatch("[^\n\r]+") do
                if line:find("Тяпка") then
                    wait(1000)
                    sampSendDialogResponse(1000, 1, count, "")
                    wait(1000)
                    sampSendDialogResponse(1001, 1, 5, "")
                    wait(1000)
                    sampCloseCurrentDialogWithButton(0)
                    actions = 0
                end
                count = count + 1
            end
        end
        count = 0
        if actions == 3 then
            for line in tx:gmatch("[^\n\r]+") do
                if line:find("Ведро с водой") then
                    wait(1000)
                    sampSendDialogResponse(1000, 1, count, "")
                    wait(1000)
                    sampSendDialogResponse(1001, 1, 5, "")
                    wait(1000)
                    sampCloseCurrentDialogWithButton(0)
                    actions = 0
                end
                count = count + 1
            end
        end
        count = 0
        if actions == 4 then
            for line in tx:gmatch("[^\n\r]+") do
                if line:find("Пакетик семян") then
                    wait(1000)
                    sampSendDialogResponse(1000, 1, count, "")
                    wait(1000)
                    sampSendDialogResponse(1001, 1, 5, "")
                    wait(1000)
                    sampCloseCurrentDialogWithButton(0)
                    actions = 0
                end
                count = count + 1
            end
        end
    end)
end

function se.onShowTextDraw(id, data)
    if actions == 5 then
        sampSendClickTextdraw(164)
        sampSendClickTextdraw(169)
        actions = 0
    end
    if actions == 6 then
        sampSendClickTextdraw(165)
        sampSendClickTextdraw(169)
        actions = 0
    end
    if actions == 7 then
        sampSendClickTextdraw(166)
        sampSendClickTextdraw(169)
        actions = 0
    end
    if actions == 8 then
        sampSendClickTextdraw(167)
        sampSendClickTextdraw(169)
        actions = 0
    end
    if actions == 9 then
        sampSendClickTextdraw(168)
        sampSendClickTextdraw(169)
        actions = 0
    end
end
Опять же Server closed the conection...

Lua:
require "lib.moonloader"
local ev = require "lib.samp.events"
local se = require "lib.samp.events"
local vkeys = require "vkeys"

actions = 0

function main()
    while true do
        wait(0)
        if isKeyJustPressed(0x69) then
            actions = 1
            sampSendChat("/invex")
        end
        if isKeyJustPressed(0x68) then
            actions = 2
            sampSendChat("/invex")
        end
        if isKeyJustPressed(0x67) then
            actions = 3
            sampSendChat("/invex")
        end
        if isKeyJustPressed(0x60) then
            actions = 4
            sampSendChat("/invex")
        end
        if isKeyJustPressed(0x61) then
            actions = 5
            sampSendChat("/pot")
        end
        if isKeyJustPressed(0x62) then
            actions = 6
            sampSendChat("/pot")
        end
        if isKeyJustPressed(0x63) then
            actions = 7
            sampSendChat("/pot")
        end
        if isKeyJustPressed(0x64) then
            actions = 8
            sampSendChat("/pot")
        end
        if isKeyJustPressed(0x65) then
            actions = 9
            sampSendChat("/pot")
        end
    end
end

function ev.onShowDialog(id, st, tit, b1, b2, tx)
    lua_thread.create(function()
        count = 0
        if actions == 1 then
            for line in tx:gmatch("[^\n\r]+") do
                if line:find("Пакет минеральных удобрений") then
                    wait(1000)
                    sampSendDialogResponse(1000, 1, count, "")
                    wait(1000)
                    sampSendDialogResponse(1001, 1, 5, "")
                    wait(1000)
                    sampCloseCurrentDialogWithButton(0)
                    actions = 0
                end
                count = count + 1
            end
        end
        count = 0
        if actions == 2 then
            for line in tx:gmatch("[^\n\r]+") do
                if line:find("Тяпка") then
                    wait(1000)
                    sampSendDialogResponse(1000, 1, count, "")
                    wait(1000)
                    sampSendDialogResponse(1001, 1, 5, "")
                    wait(1000)
                    sampCloseCurrentDialogWithButton(0)
                    actions = 0
                end
                count = count + 1
            end
        end
        count = 0
        if actions == 3 then
            for line in tx:gmatch("[^\n\r]+") do
                if line:find("Ведро с водой") then
                    wait(1000)
                    sampSendDialogResponse(1000, 1, count, "")
                    wait(1000)
                    sampSendDialogResponse(1001, 1, 5, "")
                    wait(1000)
                    sampCloseCurrentDialogWithButton(0)
                    actions = 0
                end
                count = count + 1
            end
        end
        count = 0
        if actions == 4 then
            for line in tx:gmatch("[^\n\r]+") do
                if line:find("Пакетик семян") then
                    wait(1000)
                    sampSendDialogResponse(1000, 1, count, "")
                    wait(1000)
                    sampSendDialogResponse(1001, 1, 5, "")
                    wait(1000)
                    sampCloseCurrentDialogWithButton(0)
                    actions = 0
                end
                count = count + 1
            end
        end
    end)
end

function se.onShowTextDraw(id, data)
    if actions == 5 then
        sampSendClickTextdraw(164)
        sampSendClickTextdraw(169)
        actions = 0
    end
    if actions == 6 then
        sampSendClickTextdraw(165)
        sampSendClickTextdraw(169)
        actions = 0
    end
    if actions == 7 then
        sampSendClickTextdraw(166)
        sampSendClickTextdraw(169)
        actions = 0
    end
    if actions == 8 then
        sampSendClickTextdraw(167)
        sampSendClickTextdraw(169)
        actions = 0
    end
    if actions == 9 then
        sampSendClickTextdraw(168)
        sampSendClickTextdraw(169)
        actions = 0
    end
end
Выкидывает с сервера после выполнения строчек: 61, 76, 91, 106
 
Последнее редактирование:

манку хлебал

Потрачен
305
121
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
попробуй, возможно сработает. лучше сразу писать что должен делать код, он у тебя написан, мягко говоря, нечитаемо
Lua:
require "lib.moonloader"
local ev = require "lib.samp.events"
local se = require "lib.samp.events"
local vkeys = require "vkeys"

actions = 0

function main()
    while true do
        wait(0)
        if isKeyJustPressed(0x69) then
            actions = 1
            sampSendChat("/invex")
        end
        if isKeyJustPressed(0x68) then
            actions = 2
            sampSendChat("/invex")
        end
        if isKeyJustPressed(0x67) then
            actions = 3
            sampSendChat("/invex")
        end
        if isKeyJustPressed(0x60) then
            actions = 4
            sampSendChat("/invex")
        end
        if isKeyJustPressed(0x61) then
            actions = 5
            sampSendChat("/pot")
        end
        if isKeyJustPressed(0x62) then
            actions = 6
            sampSendChat("/pot")
        end
        if isKeyJustPressed(0x63) then
            actions = 7
            sampSendChat("/pot")
        end
        if isKeyJustPressed(0x64) then
            actions = 8
            sampSendChat("/pot")
        end
        if isKeyJustPressed(0x65) then
            actions = 9
            sampSendChat("/pot")
        end
    end
end

function ev.onShowDialog(id, st, tit, b1, b2, tx)
    lua_thread.create(function()
        count = 0
        if actions == 1 then
            for line in tx:gmatch("[^\n\r]+") do
                if line:find("Пакет минеральных удобрений") then
                    wait(1000)
                    sampSendDialogResponse(id, 1, count, "")
                    wait(1000)
                    sampSendDialogResponse(id + 1, 1, 5, "")
                    actions = 0
                end
                count = count + 1
            end
            return false
        end
        count = 0
        if actions == 2 then
            for line in tx:gmatch("[^\n\r]+") do
                if line:find("Тяпка") then
                    wait(1000)
                    sampSendDialogResponse(id, 1, count, "")
                    wait(1000)
                    sampSendDialogResponse(id + 1, 1, 5, "")
                    actions = 0
                end
                count = count + 1
            end
            return false
        end
        count = 0
        if actions == 3 then
            for line in tx:gmatch("[^\n\r]+") do
                if line:find("Ведро с водой") then
                    wait(1000)
                    sampSendDialogResponse(id, 1, count, "")
                    wait(1000)
                    sampSendDialogResponse(id + 1, 1, 5, "")
                    actions = 0
                end
                count = count + 1
            end
            return false
        end
        count = 0
        if actions == 4 then
            for line in tx:gmatch("[^\n\r]+") do
                if line:find("Пакетик семян") then
                    wait(1000)
                    sampSendDialogResponse(id, 1, count, "")
                    wait(1000)
                    sampSendDialogResponse(id + 1, 1, 5, "")
                    actions = 0
                end
                count = count + 1
            end
            return false
        end
    end)
end

function se.onShowTextDraw(id, data)
    if actions == 5 then
        sampSendClickTextdraw(164)
        sampSendClickTextdraw(169)
        actions = 0
    end
    if actions == 6 then
        sampSendClickTextdraw(165)
        sampSendClickTextdraw(169)
        actions = 0
    end
    if actions == 7 then
        sampSendClickTextdraw(166)
        sampSendClickTextdraw(169)
        actions = 0
    end
    if actions == 8 then
        sampSendClickTextdraw(167)
        sampSendClickTextdraw(169)
        actions = 0
    end
    if actions == 9 then
        sampSendClickTextdraw(168)
        sampSendClickTextdraw(169)
        actions = 0
    end
end
 
  • Нравится
Реакции: Yelawolf

Yelawolf

Участник
Автор темы
14
3
попробуй, возможно сработает. лучше сразу писать что должен делать код, он у тебя написан, мягко говоря, нечитаемо
Lua:
require "lib.moonloader"
local ev = require "lib.samp.events"
local se = require "lib.samp.events"
local vkeys = require "vkeys"

actions = 0

function main()
    while true do
        wait(0)
        if isKeyJustPressed(0x69) then
            actions = 1
            sampSendChat("/invex")
        end
        if isKeyJustPressed(0x68) then
            actions = 2
            sampSendChat("/invex")
        end
        if isKeyJustPressed(0x67) then
            actions = 3
            sampSendChat("/invex")
        end
        if isKeyJustPressed(0x60) then
            actions = 4
            sampSendChat("/invex")
        end
        if isKeyJustPressed(0x61) then
            actions = 5
            sampSendChat("/pot")
        end
        if isKeyJustPressed(0x62) then
            actions = 6
            sampSendChat("/pot")
        end
        if isKeyJustPressed(0x63) then
            actions = 7
            sampSendChat("/pot")
        end
        if isKeyJustPressed(0x64) then
            actions = 8
            sampSendChat("/pot")
        end
        if isKeyJustPressed(0x65) then
            actions = 9
            sampSendChat("/pot")
        end
    end
end

function ev.onShowDialog(id, st, tit, b1, b2, tx)
    lua_thread.create(function()
        count = 0
        if actions == 1 then
            for line in tx:gmatch("[^\n\r]+") do
                if line:find("Пакет минеральных удобрений") then
                    wait(1000)
                    sampSendDialogResponse(id, 1, count, "")
                    wait(1000)
                    sampSendDialogResponse(id + 1, 1, 5, "")
                    actions = 0
                end
                count = count + 1
            end
            return false
        end
        count = 0
        if actions == 2 then
            for line in tx:gmatch("[^\n\r]+") do
                if line:find("Тяпка") then
                    wait(1000)
                    sampSendDialogResponse(id, 1, count, "")
                    wait(1000)
                    sampSendDialogResponse(id + 1, 1, 5, "")
                    actions = 0
                end
                count = count + 1
            end
            return false
        end
        count = 0
        if actions == 3 then
            for line in tx:gmatch("[^\n\r]+") do
                if line:find("Ведро с водой") then
                    wait(1000)
                    sampSendDialogResponse(id, 1, count, "")
                    wait(1000)
                    sampSendDialogResponse(id + 1, 1, 5, "")
                    actions = 0
                end
                count = count + 1
            end
            return false
        end
        count = 0
        if actions == 4 then
            for line in tx:gmatch("[^\n\r]+") do
                if line:find("Пакетик семян") then
                    wait(1000)
                    sampSendDialogResponse(id, 1, count, "")
                    wait(1000)
                    sampSendDialogResponse(id + 1, 1, 5, "")
                    actions = 0
                end
                count = count + 1
            end
            return false
        end
    end)
end

function se.onShowTextDraw(id, data)
    if actions == 5 then
        sampSendClickTextdraw(164)
        sampSendClickTextdraw(169)
        actions = 0
    end
    if actions == 6 then
        sampSendClickTextdraw(165)
        sampSendClickTextdraw(169)
        actions = 0
    end
    if actions == 7 then
        sampSendClickTextdraw(166)
        sampSendClickTextdraw(169)
        actions = 0
    end
    if actions == 8 then
        sampSendClickTextdraw(167)
        sampSendClickTextdraw(169)
        actions = 0
    end
    if actions == 9 then
        sampSendClickTextdraw(168)
        sampSendClickTextdraw(169)
        actions = 0
    end
end
На сервере есть диалог, он открывается по команде. В начале скрипта - кнопки активации по которым исполняется код внутри хука
onShowDialog. Нажимаешь на любую из клавиш активации - открывается этот диалог, в зависимости от нажатой клавиши выполняется определенный блок внутри хука. Так вот скрипту нужно найти определенную строчку в диалоге Listbox, он её находит и тыкает по ней. Открывается следующий диалог, где скрипт тоже должен выбрать строчку в Listbox'е. После этого нас перебрасывает в начальный диалог который нужно просто закрыть. После этого закрытия почему то сервер закрывает соединение.
 

манку хлебал

Потрачен
305
121
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
На сервере есть диалог, он открывается по команде. В начале скрипта - кнопки активации по которым исполняется код внутри хука
onShowDialog. Нажимаешь на любую из клавиш активации - открывается этот диалог, в зависимости от нажатой клавиши выполняется определенный блок внутри хука. Так вот скрипту нужно найти определенную строчку в диалоге Listbox, он её находит и тыкает по ней. Открывается следующий диалог, где скрипт тоже должен выбрать строчку в Listbox'е. После этого нас перебрасывает в начальный диалог который нужно просто закрыть. После этого закрытия почему то сервер закрывает соединение.
Зачем искать определенную строчку? Они местами меняются? Можно цифрой указать
 
  • Нравится
Реакции: Yelawolf

Yelawolf

Участник
Автор темы
14
3
Зачем искать определенную строчку? Они местами меняются? Можно цифрой указать
Да, это инвентарь. Поэтому почти всегда будет разное расположение у того или иного предмета. А во втором диалоге всегда все на своем месте.

Решил проблему. Спасибо что помогал такому дебилу как я).
 
Последнее редактирование: