Меню взаимодействий lua imgui

hurkas

Новичок
Автор темы
15
0
Версия MoonLoader
Другое
Как добавить несколько кнопок, которые забинжены на несколько команд в меню взаимодействий
ось код
Код:
local imgui = require 'imgui'

local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local sett = imgui.ImBool(false)
local cmds = imgui.ImBuffer(512)

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end

    while true do wait(0)
        imgui.ShowCursor = sett.v
        imgui.Process = sett.v
        if isKeyJustPressed(18) and isKeyJustPressed(2) then
            validtar, pedtar = getCharPlayerIsTargeting(playerHandle)
            if validtar and doesCharExist(pedtar) then
                local result, id = sampGetPlayerIdByCharHandle(pedtar)
                if result then
                    cmds.v = '/hi '..id
                    sett.v = true
                end
            end
        end

    end
end


function imgui.OnDrawFrame()
    if sett.v then
        imgui.Begin(u8'Окно а хули не окно?',sett, imgui.WindowFlags_AlwaysAutoResize) -- флаг авторазмера окна = imgui.WindowFlags_AlwaysAutoResize
            if imgui.Button(u8'Приветствие ') then
                sampSendChat(u8:decode(cmds.v))
            end imgui.SameLine()

        imgui.End()
    end
end
и тип как сделать так когда появляется само окно взаимодействий то там были еще кнопки с командами, а не только приветствие.
Например /cuff
 
  • Грустно
Реакции: qdIbp
Решение
Lua:
local imgui = require 'imgui'

local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local sett = imgui.ImBool(false)
local cmds = imgui.ImBuffer(512)
local idys = -1

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end

    while true do wait(0)
        imgui.ShowCursor = sett.v
        imgui.Process = sett.v
        if isKeyJustPressed(18) and isKeyJustPressed(2) then
            validtar, pedtar = getCharPlayerIsTargeting(playerHandle)
            if validtar and doesCharExist(pedtar) then
                local result, id = sampGetPlayerIdByCharHandle(pedtar)
                if result then
                    cmds.v =...

qdIbp

Автор темы
Проверенный
1,386
1,139
Lua:
local imgui = require 'imgui'

local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local sett = imgui.ImBool(false)
local cmds = imgui.ImBuffer(512)
local idys = -1

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end

    while true do wait(0)
        imgui.ShowCursor = sett.v
        imgui.Process = sett.v
        if isKeyJustPressed(18) and isKeyJustPressed(2) then
            validtar, pedtar = getCharPlayerIsTargeting(playerHandle)
            if validtar and doesCharExist(pedtar) then
                local result, id = sampGetPlayerIdByCharHandle(pedtar)
                if result then
                    cmds.v = '/hi '..id
                    idys = id
                    sett.v = true
                end
            end
        end

    end
end


function imgui.OnDrawFrame()
    if sett.v then
        imgui.Begin(u8'Окно а хули не окно?',sett, imgui.WindowFlags_AlwaysAutoResize) -- флаг авторазмера окна = imgui.WindowFlags_AlwaysAutoResize
            if imgui.Button(u8'Приветствие ') then
                sampSendChat(u8:decode(cmds.v))
            end imgui.SameLine()
            imgui.InputText(u8'Вводить команду сюда', cmds)
            if imgui.Button(u8'Наручники') then
                lua_thread.create(function()
                    sampSendChat('/me снял наручники с пояса')
                    wait(1200)
                    sampSendChat('/do Наручники в руках')
                    wait(1200)
                    sampSendChat('/me надел наручники на '..sampGetPlayerNickname(idys))
                    wait(500)
                    sampSendChat('/cuff '..idys)
                    
                end)
            end
        imgui.End()
    end
end
 
  • Нравится
Реакции: hurkas