банальный эррор, решить который мне не удается

notInsane

Известный
Автор темы
3
0
Версия MoonLoader
.026-beta
Lua:
require 'lib.moonloader'
local vk = require 'lib.vkeys'
local sampev = require 'lib.samp.events'

local function sendGetGunsAndSelectOption(downCount)
    if isSampAvailable() then
        sampSendChat("/get guns")
        lua_thread.create(function()
            wait(100)
            for i = 1, downCount do
                sampSendDialogResponse(1, 2, 0, "")
                wait(50)
            end
            sampSendDialogResponse(1, 1, 0, "")
        end)
    else
        print("-.")
    end
end

function onHotKeyPress(key)
    if key == vk.VK_MENU then
        if isKeyDown(vk.VK_1) then
            sendGetGunsAndSelectOption(4)
        elseif isKeyDown(vk.VK_2) then
            sendGetGunsAndSelectOption(8)
        end
    end
end

function main()
    if not isSampLoaded() then return end
    while true do
        wait(0)
        if isKeyDown(vk.VK_MENU) then
            if isKeyDown(vk.VK_1) then
                onHotKeyPress(vk.VK_MENU)
            elseif isKeyDown(vk.VK_2) then
                onHotKeyPress(vk.VK_MENU)
            end
        end
    end
end

main()

в двух словах по нажатию альт+1 должна прописываться команда и выбираться пятый элемент диалогового окна ( изначально писалось на ахк, поэтому и сделал типа 5 скроллдаунов стрелочкой ) после чего энтер, по нажатию альт+2 выбирался бы восьмой элемент и тоже ентер. писалось на ахк. попробовал написать сам и допилил слегка гпт. ну не пашет совершенно. прошу помочь гуру луа
 

Masayuki

Участник
33
13
Код:
local sampev = require 'samp.events'

function main()
    while not isSampAvailable() do wait(0) end
        
    while true do
        wait(0)
        if isKeyDown(0x12) and isKeyJustPressed(0x31) then
            sampSendChat('/mm') --команда
            inputNumber = 5 --нужная строка в диалоговом окне
        end
        if isKeyDown(0x12) and isKeyJustPressed(0x32) then
            sampSendChat('/mm') --команда
            inputNumber = 8 --нужная строка в диалоговом окне
        end
    end
end

function sampev.onShowDialog(id, style, title, button1, button2, text)
    if title:find('заголовок диалогового окна') and inputNumber ~= nil then --здесь укажи заголовок нужного диалога
        sampSendDialogResponse(id, 2, inputNumber, nil)
        inputNumber = nil
        return false
    end
end
 
  • Нравится
Реакции: notInsane

notInsane

Известный
Автор темы
3
0
Код:
local sampev = require 'samp.events'

function main()
    while not isSampAvailable() do wait(0) end
       
    while true do
        wait(0)
        if isKeyDown(0x12) and isKeyJustPressed(0x31) then
            sampSendChat('/mm') --команда
            inputNumber = 5 --нужная строка в диалоговом окне
        end
        if isKeyDown(0x12) and isKeyJustPressed(0x32) then
            sampSendChat('/mm') --команда
            inputNumber = 8 --нужная строка в диалоговом окне
        end
    end
end

function sampev.onShowDialog(id, style, title, button1, button2, text)
    if title:find('заголовок диалогового окна') and inputNumber ~= nil then --здесь укажи заголовок нужного диалога
        sampSendDialogResponse(id, 2, inputNumber, nil)
        inputNumber = nil
        return false
    end
end
ты бог бля) спасибо большое