вопрос по imgui

kwzInside

Участник
Автор темы
65
7
Версия MoonLoader
.027.0-preview
взял за основу пример авто обьяв, хотел объединить функцию main() но скрипт не робит так, помогите как объединить 2 функции в main(), или я что то до этого неправильно ввел?
Код:
require 'moonloader'
local imgui = require 'mimgui'
local sampev = require 'lib.samp.events'
local ffi = require 'ffi'
local encoding = require 'encoding'
encoding.default = 'CP1251'
local u8 = encoding.UTF8
local new, str = imgui.new, ffi.string
local inputField = new.char[256]()
local sizeX, sizeY = getScreenResolution()
imgui.OnInitialize(function()
    theme()
end)
local list = {
    commands = {[[123 test]]}
}
local WinState, sec, min, vra, schat, jchat, dep, narko = new.bool(), new.int(0), new.int(0), new.bool(), new.bool(), new.bool(), new.bool(), new.bool()
local status = false
local newFrame = imgui.OnFrame(
    function() return WinState[0] end,
    function(player)
        imgui.SetNextWindowPos(imgui.ImVec2(sizeX / 4, sizeY / 4), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(370, 190), imgui.Cond.Always)
        imgui.Begin('AutoAD', WinState, imgui.WindowFlags.NoResize)
        if imgui.CollapsingHeader(u8'Информация') then
            imgui.TextWrapped(u8(table.concat(list.commands, '\n')), imgui.GetWindowSize())
        end
        imgui.Separator()
        imgui.PushItemWidth(250)
        imgui.InputTextWithHint(u8' - Enter the text', u8'Любой текст', inputField, 256)
        imgui.Separator()
        imgui.PopItemWidth()
        if imgui.Button(u8"Запустить") and inputField ~= nil and status == false then
            if sec[0] ~= 0 or min[0] ~= 0 then
                status = true
            end
        end
        imgui.SameLine()
        if imgui.Button(u8"Остановить") then status = false end
        imgui.SameLine()
        imgui.Checkbox('/vr', vra)
        imgui.SameLine()
        imgui.Checkbox('/s', schat)
        imgui.SameLine()
        imgui.Checkbox('/j', jchat)
        imgui.SameLine()
        imgui.Checkbox('/d', dep)
        imgui.SliderInt(u8'Секунды', sec, 0, 60)
        imgui.SliderInt(u8'Минуты', min, 0, 60)
        imgui.Separator()
        imgui.SameLine()
        imgui.Checkbox('Нарко на Z', narko)
        imgui.End()
    end
)
function main()
    while not isSampAvailable() do wait(50) end
    sampRegisterChatCommand('aad', function() WinState[0] = not WinState[0] end)
    while true do wait(0)
        while true do wait(0)
            if narko.v then
                if isKeyJustPressed(VK_Z) then
                    sampSendChat('/usedrugs 3')
                end
            end
        end
    end
    while true do
        if status then
            wait((sec[0])*1000)
            wait(min[0]*60000)
            if vra[0] and status then
                sampSendChat('/vr '..u8:decode(str(inputField)))
            end
            if schat[0] and status then
                sampSendChat('/s '..u8:decode(str(inputField)))
            end
            if jchat[0] and status then
                sampSendChat('/j ' ..u8:decode(str(inputField)))
            end
            if dep[0] and status then
                sampSendChat('/d ' ..u8:decode(str(inputField)))
            end
        end
        wait(0)
    end
end
function sampev.onShowDialog(id, style, title, button1, button2, text)
    if status and vra[0] then
        if text:match('Ваше сообщение является рекламой') then
            sampSendDialogResponse(id,1,0,'')
            return false
        end
    end
end
 

MLycoris

Режим чтения
Проверенный
1,821
1,860
в мимгуи для проверки состояния используется ключ [0], ты же ввёл ключ имгуи .v
narko.v - имгуи
narko[0] - мимгуи
Lua:
function main()
    while not isSampAvailable() do wait(50) end
    sampRegisterChatCommand('aad', function() WinState[0] = not WinState[0] end)
    while true do
        if narko[0] then
            if isKeyJustPressed(VK_Z) and not sampIsCursorActive() then
                sampSendChat('/usedrugs 3')
            end
        end
        if status then
            wait((sec[0])*1000)
            wait(min[0]*60000)
            if vra[0] and status then
                sampSendChat('/vr '..u8:decode(str(inputField)))
            end
            if schat[0] and status then
                sampSendChat('/s '..u8:decode(str(inputField)))
            end
            if jchat[0] and status then
                sampSendChat('/j ' ..u8:decode(str(inputField)))
            end
            if dep[0] and status then
                sampSendChat('/d ' ..u8:decode(str(inputField)))
            end
        end
        wait(0)
    end
end
 

LiL STANLEY

Активный
146
43
Так?
Lua:
require 'moonloader'
local imgui = require 'mimgui'
local sampev = require 'lib.samp.events'
local ffi = require 'ffi'
local encoding = require 'encoding'
encoding.default = 'CP1251'
local u8 = encoding.UTF8
local new, str = imgui.new, ffi.string
local inputField = new.char[256]()
local sizeX, sizeY = getScreenResolution()
imgui.OnInitialize(function()
    theme()
end)
local list = {
    commands = {[[123 test]]}
}
local WinState, sec, min, vra, schat, jchat, dep, narko = new.bool(), new.int(0), new.int(0), new.bool(), new.bool(), new.bool(), new.bool(), new.bool()
local status = false
local newFrame = imgui.OnFrame(
    function() return WinState[0] end,
    function(player)
        imgui.SetNextWindowPos(imgui.ImVec2(sizeX / 4, sizeY / 4), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(370, 190), imgui.Cond.Always)
        imgui.Begin('AutoAD', WinState, imgui.WindowFlags.NoResize)
        if imgui.CollapsingHeader(u8'Информация') then
            imgui.TextWrapped(u8(table.concat(list.commands, '\n')), imgui.GetWindowSize())
        end
        imgui.Separator()
        imgui.PushItemWidth(250)
        imgui.InputTextWithHint(u8' - Enter the text', u8'Любой текст', inputField, 256)
        imgui.Separator()
        imgui.PopItemWidth()
        if imgui.Button(u8"Запустить") and inputField ~= nil and status == false then
            if sec[0] ~= 0 or min[0] ~= 0 then
                status = true
            end
        end
        imgui.SameLine()
        if imgui.Button(u8"Остановить") then status = false end
        imgui.SameLine()
        imgui.Checkbox('/vr', vra)
        imgui.SameLine()
        imgui.Checkbox('/s', schat)
        imgui.SameLine()
        imgui.Checkbox('/j', jchat)
        imgui.SameLine()
        imgui.Checkbox('/d', dep)
        imgui.SliderInt(u8'Секунды', sec, 0, 60)
        imgui.SliderInt(u8'Минуты', min, 0, 60)
        imgui.Separator()
        imgui.SameLine()
        imgui.Checkbox('Нарко на Z', narko)
        imgui.End()
    end
)
function main()
    while not isSampAvailable() do wait(50) end
    sampRegisterChatCommand('aad', function() WinState[0] = not WinState[0] end)
    while true do wait(0)
        if narko.v then
            if isKeyJustPressed(VK_Z) then
                sampSendChat('/usedrugs 3')
            end
        end
        if status then
            wait((sec[0])*1000)
            wait(min[0]*60000)
            if vra[0] and status then
                sampSendChat('/vr '..u8:decode(str(inputField)))
            end
            if schat[0] and status then
                sampSendChat('/s '..u8:decode(str(inputField)))
            end
            if jchat[0] and status then
                sampSendChat('/j ' ..u8:decode(str(inputField)))
            end
            if dep[0] and status then
                sampSendChat('/d ' ..u8:decode(str(inputField)))
            end
        end   
    end
end

function sampev.onShowDialog(id, style, title, button1, button2, text)
    if status and vra[0] then
        if text:match('Ваше сообщение является рекламой') then
            sampSendDialogResponse(id,1,0,'')
            return false
        end
    end
end
 

kwzInside

Участник
Автор темы
65
7
в мимгуи для проверки состояния используется ключ [0], ты же ввёл ключ имгуи .v
narko.v - имгуи
narko[0] - мимгуи
Lua:
function main()
    while not isSampAvailable() do wait(50) end
    sampRegisterChatCommand('aad', function() WinState[0] = not WinState[0] end)
    while true do
        if narko[0] then
            if isKeyJustPressed(VK_Z) and not sampIsCursorActive() then
                sampSendChat('/usedrugs 3')
            end
        end
        if status then
            wait((sec[0])*1000)
            wait(min[0]*60000)
            if vra[0] and status then
                sampSendChat('/vr '..u8:decode(str(inputField)))
            end
            if schat[0] and status then
                sampSendChat('/s '..u8:decode(str(inputField)))
            end
            if jchat[0] and status then
                sampSendChat('/j ' ..u8:decode(str(inputField)))
            end
            if dep[0] and status then
                sampSendChat('/d ' ..u8:decode(str(inputField)))
            end
        end
        wait(0)
    end
end
не работает, может ошибка была до функции main()?
 

LiL STANLEY

Активный
146
43

MLycoris

Режим чтения
Проверенный
1,821
1,860
Lua:
require 'moonloader'
local imgui = require 'mimgui'
local sampev = require 'lib.samp.events'
local ffi = require 'ffi'
local encoding = require 'encoding'
encoding.default = 'CP1251'
local u8 = encoding.UTF8
local new, str = imgui.new, ffi.string
local inputField = new.char[256]()
local sizeX, sizeY = getScreenResolution()
local list = {
    commands = {[[123 test]]}
}
local WinState, sec, min, vra, schat, jchat, dep, narko = new.bool(), new.int(0), new.int(0), new.bool(), new.bool(), new.bool(), new.bool(), new.bool()
local status = false
local newFrame = imgui.OnFrame(
    function() return WinState[0] end,
    function(player)
        imgui.SetNextWindowPos(imgui.ImVec2(sizeX / 4, sizeY / 4), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(370, 190), imgui.Cond.Always)
        imgui.Begin('AutoAD', WinState, imgui.WindowFlags.NoResize)
        if imgui.CollapsingHeader(u8'Информация') then
            imgui.TextWrapped(u8(table.concat(list.commands, '\n')), imgui.GetWindowSize())
        end
        imgui.Separator()
        imgui.PushItemWidth(250)
        imgui.InputTextWithHint(u8' - Enter the text', u8'Любой текст', inputField, 256)
        imgui.Separator()
        imgui.PopItemWidth()
        if imgui.Button(u8"Запустить") and inputField ~= nil and status == false then
            if sec[0] ~= 0 or min[0] ~= 0 then
                status = true
            end
        end
        imgui.SameLine()
        if imgui.Button(u8"Остановить") then status = false end
        imgui.SameLine()
        imgui.Checkbox('/vr', vra)
        imgui.SameLine()
        imgui.Checkbox('/s', schat)
        imgui.SameLine()
        imgui.Checkbox('/j', jchat)
        imgui.SameLine()
        imgui.Checkbox('/d', dep)
        imgui.SliderInt(u8'Секунды', sec, 0, 60)
        imgui.SliderInt(u8'Минуты', min, 0, 60)
        imgui.Separator()
        imgui.SameLine()
        imgui.Checkbox(u8'Нарко на Z', narko)
        imgui.End()
    end
)
function main()
    while not isSampAvailable() do wait(50) end
    sampRegisterChatCommand('aad', function() WinState[0] = not WinState[0] end)
    while true do wait(0)
        if narko[0] then
            if isKeyJustPressed(VK_Z) then
                sampSendChat('/usedrugs 3')
            end
        end
        if status then
            wait((sec[0])*1000)
            wait(min[0]*60000)
            if vra[0] and status then
                sampSendChat('/vr '..u8:decode(str(inputField)))
            end
            if schat[0] and status then
                sampSendChat('/s '..u8:decode(str(inputField)))
            end
            if jchat[0] and status then
                sampSendChat('/j ' ..u8:decode(str(inputField)))
            end
            if dep[0] and status then
                sampSendChat('/d ' ..u8:decode(str(inputField)))
            end
        end
    end
end
function sampev.onShowDialog(id, style, title, button1, button2, text)
    if status and vra[0] then
        if text:match('Ваше сообщение является рекламой') then
            sampSendDialogResponse(id,1,0,'')
            return false
        end
    end
end
 

LiL STANLEY

Активный
146
43
Lua:
require 'moonloader'
local imgui = require 'mimgui'
local sampev = require 'lib.samp.events'
local ffi = require 'ffi'
local encoding = require 'encoding'
encoding.default = 'CP1251'
local u8 = encoding.UTF8
local new, str = imgui.new, ffi.string
local inputField = new.char[256]()
local sizeX, sizeY = getScreenResolution()
imgui.OnInitialize(function()
    theme()
end)
local list = {
    commands = {[[123 test]]}
}
local WinState, sec, min, vra, schat, jchat, dep, narko = new.bool(), new.int(0), new.int(0), new.bool(), new.bool(), new.bool(), new.bool(), new.bool()
local status = false
local newFrame = imgui.OnFrame(
    function() return WinState[0] end,
    function(player)
        imgui.SetNextWindowPos(imgui.ImVec2(sizeX / 4, sizeY / 4), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(370, 190), imgui.Cond.Always)
        imgui.Begin('AutoAD', WinState, imgui.WindowFlags.NoResize)
        if imgui.CollapsingHeader(u8'Информация') then
            imgui.TextWrapped(u8(table.concat(list.commands, '\n')), imgui.GetWindowSize())
        end
        imgui.Separator()
        imgui.PushItemWidth(250)
        imgui.InputTextWithHint(u8' - Enter the text', u8'Любой текст', inputField, 256)
        imgui.Separator()
        imgui.PopItemWidth()
        if imgui.Button(u8"Запустить") and inputField ~= nil and status == false then
            if sec[0] ~= 0 or min[0] ~= 0 then
                status = true
            end
        end
        imgui.SameLine()
        if imgui.Button(u8"Остановить") then status = false end
        imgui.SameLine()
        imgui.Checkbox('/vr', vra)
        imgui.SameLine()
        imgui.Checkbox('/s', schat)
        imgui.SameLine()
        imgui.Checkbox('/j', jchat)
        imgui.SameLine()
        imgui.Checkbox('/d', dep)
        imgui.SliderInt(u8'Секунды', sec, 0, 60)
        imgui.SliderInt(u8'Минуты', min, 0, 60)
        imgui.Separator()
        imgui.SameLine()
        imgui.Checkbox('Нарко на Z', narko)
        imgui.End()
    end
)
function main()
    while not isSampAvailable() do wait(50) end
    sampRegisterChatCommand('aad', function() WinState[0] = not WinState[0] end)
    while true do
    wait(0)
        if narko[0] then
            if isKeyJustPressed(VK_Z) then
                sampSendChat('/usedrugs 3')
            end
        end
        if status then
            wait((sec[0])*1000)
            wait(min[0]*60000)
            if vra[0] and status.v then
                sampSendChat('/vr '..u8:decode(str(inputField)))
            end
            if schat[0] and status then
                sampSendChat('/s '..u8:decode(str(inputField)))
            end
            if jchat[0] and status then
                sampSendChat('/j ' ..u8:decode(str(inputField)))
            end
            if dep[0] and status then
                sampSendChat('/d ' ..u8:decode(str(inputField)))
            end
        end
       end
end


function sampev.onShowDialog(id, style, title, button1, button2, text)
    if status and vra[0] then
        if text:match('Ваше сообщение является рекламой') then
            sampSendDialogResponse(id,1,0,'')
            return false
        end
    end
end

Lua:
require 'moonloader'
local imgui = require 'mimgui'
local sampev = require 'lib.samp.events'
local ffi = require 'ffi'
local encoding = require 'encoding'
encoding.default = 'CP1251'
local u8 = encoding.UTF8
local new, str = imgui.new, ffi.string
local inputField = new.char[256]()
local sizeX, sizeY = getScreenResolution()
local list = {
    commands = {[[123 test]]}
}
local WinState, sec, min, vra, schat, jchat, dep, narko = new.bool(), new.int(0), new.int(0), new.bool(), new.bool(), new.bool(), new.bool(), new.bool()
local status = false
local newFrame = imgui.OnFrame(
    function() return WinState[0] end,
    function(player)
        imgui.SetNextWindowPos(imgui.ImVec2(sizeX / 4, sizeY / 4), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(370, 190), imgui.Cond.Always)
        imgui.Begin('AutoAD', WinState, imgui.WindowFlags.NoResize)
        if imgui.CollapsingHeader(u8'Информация') then
            imgui.TextWrapped(u8(table.concat(list.commands, '\n')), imgui.GetWindowSize())
        end
        imgui.Separator()
        imgui.PushItemWidth(250)
        imgui.InputTextWithHint(u8' - Enter the text', u8'Любой текст', inputField, 256)
        imgui.Separator()
        imgui.PopItemWidth()
        if imgui.Button(u8"Запустить") and inputField ~= nil and status == false then
            if sec[0] ~= 0 or min[0] ~= 0 then
                status = true
            end
        end
        imgui.SameLine()
        if imgui.Button(u8"Остановить") then status = false end
        imgui.SameLine()
        imgui.Checkbox('/vr', vra)
        imgui.SameLine()
        imgui.Checkbox('/s', schat)
        imgui.SameLine()
        imgui.Checkbox('/j', jchat)
        imgui.SameLine()
        imgui.Checkbox('/d', dep)
        imgui.SliderInt(u8'Секунды', sec, 0, 60)
        imgui.SliderInt(u8'Минуты', min, 0, 60)
        imgui.Separator()
        imgui.SameLine()
        imgui.Checkbox(u8'Нарко на Z', narko)
        imgui.End()
    end
)
function main()
    while not isSampAvailable() do wait(50) end
    sampRegisterChatCommand('aad', function() WinState[0] = not WinState[0] end)
    while true do wait(0)
        if narko[0] then
            if isKeyJustPressed(VK_Z) then
                sampSendChat('/usedrugs 3')
            end
        end
        if status then
            wait((sec[0])*1000)
            wait(min[0]*60000)
            if vra[0] and status then
                sampSendChat('/vr '..u8:decode(str(inputField)))
            end
            if schat[0] and status then
                sampSendChat('/s '..u8:decode(str(inputField)))
            end
            if jchat[0] and status then
                sampSendChat('/j ' ..u8:decode(str(inputField)))
            end
            if dep[0] and status then
                sampSendChat('/d ' ..u8:decode(str(inputField)))
            end
        end
    end
end
function sampev.onShowDialog(id, style, title, button1, button2, text)
    if status and vra[0] then
        if text:match('Ваше сообщение является рекламой') then
            sampSendDialogResponse(id,1,0,'')
            return false
        end
    end
end
Для чего ты используешь кодировку мимгуи?
А не,я тупой,только сейчас увидел мимгуи
 
  • Вау
Реакции: Lance_Sterling