Не работает регистер команды

Infinqxw

Новичок
Автор темы
27
1
чет не работает команда, но в консоли она есть.
Ещё при запуске игры запускается имгуи меню

Lua:
local imgui = require('imgui')
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
       
local window = imgui.ImBool(false)

local inicfg = require 'inicfg'
local directIni = 'pitbull.ini'
local ini = inicfg.load(inicfg.load({
    main = {
        enabled = true
    },
}, directIni))
inicfg.save(ini, directIni)
       
function main()
    while not isSampAvailable() do wait(200) end
    imgui.Process = false
    sampRegisterChatCommand("rehelp", cmd_rehelp)
    window.v = true  --show window on start
    while true do
        wait(0)
        imgui.Process = window.v
    end
end

function cmd_rehelp(arg)
    if #arg == 0 then
      print("Command 'rehelp' syntax: /rehelp [something]")
    else
      print(": input = " .. arg)
    end
  end
       
function imgui.OnDrawFrame()
    if window.v then
        local resX, resY = getScreenResolution()
        local sizeX, sizeY = 300, 300 -- WINDOW SIZE
        imgui.SetNextWindowPos(imgui.ImVec2(resX / 2 - sizeX / 2, resY / 2 - sizeY / 2), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowSize(imgui.ImVec2(sizeX, sizeY), imgui.Cond.FirstUseEver)
        imgui.Begin('Window Title', window)
        --window code
        imgui.End()
    end
end
 

IlyaFontonov

Активный
126
31
/menu - открыть/закрыть меню

Код:
local imgui = require('imgui')
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
      
local window = imgui.ImBool(false)

local inicfg = require 'inicfg'
local directIni = 'pitbull.ini'
local ini = inicfg.load(inicfg.load({
    main = {
        enabled = true
    },
}, directIni))
inicfg.save(ini, directIni)
      
function main()
    while not isSampAvailable() do wait(200) end
    imgui.Process = false
    sampRegisterChatCommand("rehelp", cmd_rehelp)
    sampRegisterChatCommand("menu", cmd_menu)
    window.v = false  --show window on start
    while true do
        wait(0)
        imgui.Process = window.v
    end
end

function cmd_rehelp(arg)
    if arg == '' then
        sampAddChatMessage("Command 'rehelp' syntax: /rehelp [something]", -1)
    else
        sampAddChatMessage(": input = " .. arg, -1)
    end
end

function cmd_menu()
    window.v = not window.v
end
      
function imgui.OnDrawFrame()
    if window.v then
        local resX, resY = getScreenResolution()
        local sizeX, sizeY = 300, 300 -- WINDOW SIZE
        imgui.SetNextWindowPos(imgui.ImVec2(resX / 2 - sizeX / 2, resY / 2 - sizeY / 2), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowSize(imgui.ImVec2(sizeX, sizeY), imgui.Cond.FirstUseEver)
        imgui.Begin('Window Title', window)
        --window code
        imgui.End()
    end
end
 
  • Нравится
Реакции: MLycoris и Infinqxw

Infinqxw

Новичок
Автор темы
27
1
/menu - открыть/закрыть меню

Код:
local imgui = require('imgui')
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
     
local window = imgui.ImBool(false)

local inicfg = require 'inicfg'
local directIni = 'pitbull.ini'
local ini = inicfg.load(inicfg.load({
    main = {
        enabled = true
    },
}, directIni))
inicfg.save(ini, directIni)
     
function main()
    while not isSampAvailable() do wait(200) end
    imgui.Process = false
    sampRegisterChatCommand("rehelp", cmd_rehelp)
    sampRegisterChatCommand("menu", cmd_menu)
    window.v = false  --show window on start
    while true do
        wait(0)
        imgui.Process = window.v
    end
end

function cmd_rehelp(arg)
    if arg == '' then
        sampAddChatMessage("Command 'rehelp' syntax: /rehelp [something]", -1)
    else
        sampAddChatMessage(": input = " .. arg, -1)
    end
end

function cmd_menu()
    window.v = not window.v
end
     
function imgui.OnDrawFrame()
    if window.v then
        local resX, resY = getScreenResolution()
        local sizeX, sizeY = 300, 300 -- WINDOW SIZE
        imgui.SetNextWindowPos(imgui.ImVec2(resX / 2 - sizeX / 2, resY / 2 - sizeY / 2), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowSize(imgui.ImVec2(sizeX, sizeY), imgui.Cond.FirstUseEver)
        imgui.Begin('Window Title', window)
        --window code
        imgui.End()
    end
end
спасибо большое