Вопрос по активации чекбокса

sauntren

Новичок
Автор темы
14
1
Версия MoonLoader
Другое
Добрый день.

Представлю код:

Код:
script_name('Sauntren Helper')
script_author('Seth Sauntren')
script_description('Helper for Arizona RP')

require "lib.moonloader"
local keys = require "vkeys"
local imgui = require 'imgui'
local encoding = require 'encoding'
local main_window_state = imgui.ImBool(false)
local secondary_window_state = imgui.ImBool(false)
local text_buffer = imgui.ImBuffer(256)
local checked_radio = imgui.ImInt(1)
local checked_test = imgui.ImBool(false)
local checked_test_2 = imgui.ImBool(false)
local sw, sh = getScreenResolution()
local themes = import "resource/imgui_themes.lua"
local combo_select = imgui.ImInt(0)
encoding.default = 'CP1251'
u8 = encoding.UTF8

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

sampAddChatMessage("[SN Helper] {D5DEDD}Version: 1.0. | Author: Seth Sauntren.", 0x01A0E9)
sampAddChatMessage("[SN Helper] {D5DEDD}Activation: /snh.", 0x01A0E9)

sampRegisterChatCommand("snh", cmd_imgui)
sampRegisterChatCommand("snh2", cmd_imgui2)

imgui.Process = false

imgui.SwitchContext()
themes.SwitchColorTheme(1)


while true do
wait(0)
end
end

function imgui.OnDrawFrame()
if main_window_state.v then
imgui.SetNextWindowSize(imgui.ImVec2(500, 600), imgui.Cond.FirstUseEver)
imgui.SetNextWindowPos(imgui.ImVec2((sw/2), sh/2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))

imgui.Begin("Sauntren Helper 1.0", main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)


imgui.BeginChild("ChildWindow", imgui.ImVec2(484, 150), true)
imgui.Checkbox("Lock cars", checked_test)
imgui.SameLine()
imgui.Checkbox("SW ST", checked_test_2)
imgui.EndChild()

imgui.InputText(u8'Введите текст:', text_buffer)
if imgui.Button(u8'Вывести в чат') then
sampAddChatMessage(u8:decode(text_buffer.v), -1)
end


imgui.SetCursorPosY(575)
imgui.SetCursorPosX(455)
if imgui.Button(u8'Темы') then
secondary_window_state.v = true
end



x, y, z = getCharCoordinates(PLAYER_PED)
imgui.SetCursorPosY(580)
imgui.SetCursorPosX(10)
imgui.Text(u8("Позиция игрока: X:" .. math.floor(x) .. " | Y: " .. math.floor(y) .. " | Z: " .. math.floor(z)))
imgui.End()
end

if main_window_state.v == false then
imgui.Process = false
end

imgui.SetNextWindowSize(imgui.ImVec2(150, 205), imgui.Cond.FirstUseEver)
imgui.SetNextWindowPos(imgui.ImVec2((sw/2), sh/2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
if secondary_window_state.v then
imgui.Begin(u8'Темы', secondary_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
imgui.BeginChild("ChildWindow2", imgui.ImVec2(140, 175), true)
for i, value in ipairs(themes.colorThemes) do
if imgui.RadioButton(value, checked_radio, i) then
themes.SwitchColorTheme(i)
end
end
imgui.EndChild()
imgui.End()
end
end




function cmd_imgui(arg)
main_window_state.v = not main_window_state.v
imgui.Process = main_window_state.v
end

function cmd_imgui2(arg)
secondary_window_state.v = not secondary_window_state.v
imgui.Process = secondary_window_state.v
end

function apply_custom_style()
imgui.SwitchContext()
local style = imgui.GetStyle()
style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
end
apply_custom_style()

Как в нём сделать бинд на активированный чекбокс?
Допустим, если чекбокс активирован, то при нажатии на кнопку P будет отправляться команда /phone в чат?

Moonloader версии 026.5-beta.

Спасибо за внимание.
 
Решение
В месте где "Код" я и затрудняюсь, если не сложно, допишите пожалуйста. На кнопку P при вкл. чекбоксе должна отправляться команда /phone
Lua:
            if CheckBox.v then
                if isKeyJustPressed(VK_P) and not sampIsCursorActive() then
                    sampSendChat('/phone')
                end
            end

VRush

https://t.me/vrushscript
Проверенный
2,344
1,091
В месте где "Код" я и затрудняюсь, если не сложно, допишите пожалуйста. На кнопку P при вкл. чекбоксе должна отправляться команда /phone
Lua:
            if CheckBox.v then
                if isKeyJustPressed(VK_P) and not sampIsCursorActive() then
                    sampSendChat('/phone')
                end
            end
 
  • Нравится
Реакции: sauntren

sauntren

Новичок
Автор темы
14
1
Все равно не работает )
В чем может быть ошибка?


Lua:
script_name('Sauntren Helper')
script_author('Seth Sauntren')
script_description('Helper for Arizona RP')

require "lib.moonloader"
local keys = require "vkeys"
local imgui = require 'imgui'
local encoding = require 'encoding'
local main_window_state = imgui.ImBool(false)
local secondary_window_state = imgui.ImBool(false)
local text_buffer = imgui.ImBuffer(256)
local checked_radio = imgui.ImInt(1)
local CheckBox = imgui.ImBool(true)
local checked_test_2 = imgui.ImBool(false)
local sw, sh = getScreenResolution()
local themes = import "resource/imgui_themes.lua"
local combo_select = imgui.ImInt(0)
encoding.default = 'CP1251'
u8 = encoding.UTF8

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

sampAddChatMessage("[SN Helper] {D5DEDD}Version: 1.0. | Author: Seth Sauntren.", 0x01A0E9)
sampAddChatMessage("[SN Helper] {D5DEDD}Activation: /snh.", 0x01A0E9)

sampRegisterChatCommand("snh", cmd_imgui)
sampRegisterChatCommand("snh2", cmd_imgui2)

imgui.Process = false

imgui.SwitchContext()
themes.SwitchColorTheme(1)

if CheckBox.v then
if isKeyJustPressed(VK_J) and not sampIsCursorActive() then
sampSendChat('/help')
end
end


while true do
wait(0)
end
end

function imgui.OnDrawFrame()
if main_window_state.v then
imgui.SetNextWindowSize(imgui.ImVec2(500, 600), imgui.Cond.FirstUseEver)
imgui.SetNextWindowPos(imgui.ImVec2((sw/2), sh/2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))

imgui.Begin("Sauntren Helper 1.0", main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)


imgui.BeginChild("ChildWindow", imgui.ImVec2(484, 150), true)
imgui.Checkbox("Guns", CheckBox)
imgui.SameLine()
imgui.Checkbox("SW ST", checked_test_2)
imgui.EndChild()

imgui.InputText(u8'Введите текст:', text_buffer)
if imgui.Button(u8'Вывести в чат') then
sampAddChatMessage(u8:decode(text_buffer.v), -1)
end


imgui.SetCursorPosY(575)
imgui.SetCursorPosX(455)
if imgui.Button(u8'Темы') then
secondary_window_state.v = true
end


x, y, z = getCharCoordinates(PLAYER_PED)
imgui.SetCursorPosY(580)
imgui.SetCursorPosX(10)
imgui.Text(u8("Позиция игрока: X:" .. math.floor(x) .. " | Y: " .. math.floor(y) .. " | Z: " .. math.floor(z)))
imgui.End()
end

if main_window_state.v == false then
imgui.Process = false
end

imgui.SetNextWindowSize(imgui.ImVec2(150, 205), imgui.Cond.FirstUseEver)
imgui.SetNextWindowPos(imgui.ImVec2((sw/2), sh/2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
if secondary_window_state.v then
imgui.Begin(u8'Темы', secondary_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
imgui.BeginChild("ChildWindow2", imgui.ImVec2(140, 175), true)
for i, value in ipairs(themes.colorThemes) do
if imgui.RadioButton(value, checked_radio, i) then
themes.SwitchColorTheme(i)
end
end
imgui.EndChild()
imgui.End()
end
end




function cmd_imgui(arg)
main_window_state.v = not main_window_state.v
imgui.Process = main_window_state.v
end

function cmd_imgui2(arg)
secondary_window_state.v = not secondary_window_state.v
imgui.Process = secondary_window_state.v
end

function apply_custom_style()
imgui.SwitchContext()
local style = imgui.GetStyle()
style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
end
apply_custom_style()

  if CheckBox.v then
                if isKeyJustPressed(VK_J) and not sampIsCursorActive() then
                    sampSendChat('/help')
                end
            end
 

VRush

https://t.me/vrushscript
Проверенный
2,344
1,091
Все равно не работает )
В чем может быть ошибка?


Lua:
script_name('Sauntren Helper')
script_author('Seth Sauntren')
script_description('Helper for Arizona RP')

require "lib.moonloader"
local keys = require "vkeys"
local imgui = require 'imgui'
local encoding = require 'encoding'
local main_window_state = imgui.ImBool(false)
local secondary_window_state = imgui.ImBool(false)
local text_buffer = imgui.ImBuffer(256)
local checked_radio = imgui.ImInt(1)
local CheckBox = imgui.ImBool(true)
local checked_test_2 = imgui.ImBool(false)
local sw, sh = getScreenResolution()
local themes = import "resource/imgui_themes.lua"
local combo_select = imgui.ImInt(0)
encoding.default = 'CP1251'
u8 = encoding.UTF8

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

sampAddChatMessage("[SN Helper] {D5DEDD}Version: 1.0. | Author: Seth Sauntren.", 0x01A0E9)
sampAddChatMessage("[SN Helper] {D5DEDD}Activation: /snh.", 0x01A0E9)

sampRegisterChatCommand("snh", cmd_imgui)
sampRegisterChatCommand("snh2", cmd_imgui2)

imgui.Process = false

imgui.SwitchContext()
themes.SwitchColorTheme(1)

if CheckBox.v then
if isKeyJustPressed(VK_J) and not sampIsCursorActive() then
sampSendChat('/help')
end
end


while true do
wait(0)
end
end

function imgui.OnDrawFrame()
if main_window_state.v then
imgui.SetNextWindowSize(imgui.ImVec2(500, 600), imgui.Cond.FirstUseEver)
imgui.SetNextWindowPos(imgui.ImVec2((sw/2), sh/2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))

imgui.Begin("Sauntren Helper 1.0", main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)


imgui.BeginChild("ChildWindow", imgui.ImVec2(484, 150), true)
imgui.Checkbox("Guns", CheckBox)
imgui.SameLine()
imgui.Checkbox("SW ST", checked_test_2)
imgui.EndChild()

imgui.InputText(u8'Введите текст:', text_buffer)
if imgui.Button(u8'Вывести в чат') then
sampAddChatMessage(u8:decode(text_buffer.v), -1)
end


imgui.SetCursorPosY(575)
imgui.SetCursorPosX(455)
if imgui.Button(u8'Темы') then
secondary_window_state.v = true
end


x, y, z = getCharCoordinates(PLAYER_PED)
imgui.SetCursorPosY(580)
imgui.SetCursorPosX(10)
imgui.Text(u8("Позиция игрока: X:" .. math.floor(x) .. " | Y: " .. math.floor(y) .. " | Z: " .. math.floor(z)))
imgui.End()
end

if main_window_state.v == false then
imgui.Process = false
end

imgui.SetNextWindowSize(imgui.ImVec2(150, 205), imgui.Cond.FirstUseEver)
imgui.SetNextWindowPos(imgui.ImVec2((sw/2), sh/2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
if secondary_window_state.v then
imgui.Begin(u8'Темы', secondary_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
imgui.BeginChild("ChildWindow2", imgui.ImVec2(140, 175), true)
for i, value in ipairs(themes.colorThemes) do
if imgui.RadioButton(value, checked_radio, i) then
themes.SwitchColorTheme(i)
end
end
imgui.EndChild()
imgui.End()
end
end




function cmd_imgui(arg)
main_window_state.v = not main_window_state.v
imgui.Process = main_window_state.v
end

function cmd_imgui2(arg)
secondary_window_state.v = not secondary_window_state.v
imgui.Process = secondary_window_state.v
end

function apply_custom_style()
imgui.SwitchContext()
local style = imgui.GetStyle()
style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
end
apply_custom_style()

  if CheckBox.v then
                if isKeyJustPressed(VK_J) and not sampIsCursorActive() then
                    sampSendChat('/help')
                end
            end
1. Табуляция.
2. У тебя if в конце кода...
 

VRush

https://t.me/vrushscript
Проверенный
2,344
1,091
Можешь инфу дать какую, статью и тд об этом?
 

sauntren

Новичок
Автор темы
14
1
гуд?

Lua:
script_name('Sauntren Helper')
script_author('Seth Sauntren')
script_description('Helper for Arizona RP')

require "lib.moonloader"
local keys = require "vkeys"
local imgui = require 'imgui'
local encoding = require 'encoding'
local main_window_state = imgui.ImBool(false)
local secondary_window_state = imgui.ImBool(false)
local text_buffer = imgui.ImBuffer(256)
local checked_radio = imgui.ImInt(1)
local CheckBox = imgui.ImBool(true)
local checked_test_2 = imgui.ImBool(false)
local sw, sh = getScreenResolution()
local themes = import "resource/imgui_themes.lua"
local combo_select = imgui.ImInt(0)
encoding.default = 'CP1251'
u8 = encoding.UTF8

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
        sampAddChatMessage("[SN Helper] {D5DEDD}Version: 1.0. | Author: Seth Sauntren.", 0x01A0E9)
        sampAddChatMessage("[SN Helper] {D5DEDD}Activation: /snh.", 0x01A0E9)

        sampRegisterChatCommand("snh", cmd_imgui)
        sampRegisterChatCommand("snh2", cmd_imgui2)

imgui.Process = false

imgui.SwitchContext()
themes.SwitchColorTheme(1)

            if CheckBox.v then
                if isKeyJustPressed(VK_J) and not sampIsCursorActive() then
                    sampSendChat('/help')
                end
            end


while true do
    wait(0)
end
end

function imgui.OnDrawFrame()
    if main_window_state.v then
        imgui.SetNextWindowSize(imgui.ImVec2(500, 600), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos(imgui.ImVec2((sw/2), sh/2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))

imgui.Begin("Sauntren Helper 1.0", main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
imgui.BeginChild("ChildWindow", imgui.ImVec2(484, 150), true)
imgui.Checkbox("Guns", CheckBox)
    imgui.SameLine()
imgui.Checkbox("SW ST", checked_test_2)
    imgui.EndChild()

imgui.InputText(u8'Введите текст:', text_buffer)
if imgui.Button(u8'Вывести в чат') then
    sampAddChatMessage(u8:decode(text_buffer.v), -1)
end


imgui.SetCursorPosY(575)
imgui.SetCursorPosX(455)
if imgui.Button(u8'Темы') then
    secondary_window_state.v = true
end


x, y, z = getCharCoordinates(PLAYER_PED)
imgui.SetCursorPosY(580)
imgui.SetCursorPosX(10)
imgui.Text(u8("Позиция игрока: X:" .. math.floor(x) .. " | Y: " .. math.floor(y) .. " | Z: " .. math.floor(z)))
imgui.End()
end

if main_window_state.v == false then
    imgui.Process = false
end

imgui.SetNextWindowSize(imgui.ImVec2(150, 205), imgui.Cond.FirstUseEver)
imgui.SetNextWindowPos(imgui.ImVec2((sw/2), sh/2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
if secondary_window_state.v then
    imgui.Begin(u8'Темы', secondary_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
    imgui.BeginChild("ChildWindow2", imgui.ImVec2(140, 175), true)
    for i, value in ipairs(themes.colorThemes) do
        if imgui.RadioButton(value, checked_radio, i) then
            themes.SwitchColorTheme(i)
        end
    end
    imgui.EndChild()
imgui.End()
end
end




function cmd_imgui(arg)
    main_window_state.v = not main_window_state.v
    imgui.Process = main_window_state.v
end

function cmd_imgui2(arg)
    secondary_window_state.v = not secondary_window_state.v
    imgui.Process = secondary_window_state.v
end

function apply_custom_style()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
end
apply_custom_style()
 
  • Ха-ха
Реакции: cort

VRush

https://t.me/vrushscript
Проверенный
2,344
1,091
гуд?

Lua:
script_name('Sauntren Helper')
script_author('Seth Sauntren')
script_description('Helper for Arizona RP')

require "lib.moonloader"
local keys = require "vkeys"
local imgui = require 'imgui'
local encoding = require 'encoding'
local main_window_state = imgui.ImBool(false)
local secondary_window_state = imgui.ImBool(false)
local text_buffer = imgui.ImBuffer(256)
local checked_radio = imgui.ImInt(1)
local CheckBox = imgui.ImBool(true)
local checked_test_2 = imgui.ImBool(false)
local sw, sh = getScreenResolution()
local themes = import "resource/imgui_themes.lua"
local combo_select = imgui.ImInt(0)
encoding.default = 'CP1251'
u8 = encoding.UTF8

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
        sampAddChatMessage("[SN Helper] {D5DEDD}Version: 1.0. | Author: Seth Sauntren.", 0x01A0E9)
        sampAddChatMessage("[SN Helper] {D5DEDD}Activation: /snh.", 0x01A0E9)

        sampRegisterChatCommand("snh", cmd_imgui)
        sampRegisterChatCommand("snh2", cmd_imgui2)

imgui.Process = false

imgui.SwitchContext()
themes.SwitchColorTheme(1)

            if CheckBox.v then
                if isKeyJustPressed(VK_J) and not sampIsCursorActive() then
                    sampSendChat('/help')
                end
            end


while true do
    wait(0)
end
end

function imgui.OnDrawFrame()
    if main_window_state.v then
        imgui.SetNextWindowSize(imgui.ImVec2(500, 600), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos(imgui.ImVec2((sw/2), sh/2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))

imgui.Begin("Sauntren Helper 1.0", main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
imgui.BeginChild("ChildWindow", imgui.ImVec2(484, 150), true)
imgui.Checkbox("Guns", CheckBox)
    imgui.SameLine()
imgui.Checkbox("SW ST", checked_test_2)
    imgui.EndChild()

imgui.InputText(u8'Введите текст:', text_buffer)
if imgui.Button(u8'Вывести в чат') then
    sampAddChatMessage(u8:decode(text_buffer.v), -1)
end


imgui.SetCursorPosY(575)
imgui.SetCursorPosX(455)
if imgui.Button(u8'Темы') then
    secondary_window_state.v = true
end


x, y, z = getCharCoordinates(PLAYER_PED)
imgui.SetCursorPosY(580)
imgui.SetCursorPosX(10)
imgui.Text(u8("Позиция игрока: X:" .. math.floor(x) .. " | Y: " .. math.floor(y) .. " | Z: " .. math.floor(z)))
imgui.End()
end

if main_window_state.v == false then
    imgui.Process = false
end

imgui.SetNextWindowSize(imgui.ImVec2(150, 205), imgui.Cond.FirstUseEver)
imgui.SetNextWindowPos(imgui.ImVec2((sw/2), sh/2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
if secondary_window_state.v then
    imgui.Begin(u8'Темы', secondary_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
    imgui.BeginChild("ChildWindow2", imgui.ImVec2(140, 175), true)
    for i, value in ipairs(themes.colorThemes) do
        if imgui.RadioButton(value, checked_radio, i) then
            themes.SwitchColorTheme(i)
        end
    end
    imgui.EndChild()
imgui.End()
end
end




function cmd_imgui(arg)
    main_window_state.v = not main_window_state.v
    imgui.Process = main_window_state.v
end

function cmd_imgui2(arg)
    secondary_window_state.v = not secondary_window_state.v
    imgui.Process = secondary_window_state.v
end

function apply_custom_style()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
end
apply_custom_style()
нет
 

kyrtion

Известный
643
238
гуд?

Lua:
script_name('Sauntren Helper')
script_author('Seth Sauntren')
script_description('Helper for Arizona RP')

require "lib.moonloader"
local keys = require "vkeys"
local imgui = require 'imgui'
local encoding = require 'encoding'
local main_window_state = imgui.ImBool(false)
local secondary_window_state = imgui.ImBool(false)
local text_buffer = imgui.ImBuffer(256)
local checked_radio = imgui.ImInt(1)
local CheckBox = imgui.ImBool(true)
local checked_test_2 = imgui.ImBool(false)
local sw, sh = getScreenResolution()
local themes = import "resource/imgui_themes.lua"
local combo_select = imgui.ImInt(0)
encoding.default = 'CP1251'
u8 = encoding.UTF8

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
        sampAddChatMessage("[SN Helper] {D5DEDD}Version: 1.0. | Author: Seth Sauntren.", 0x01A0E9)
        sampAddChatMessage("[SN Helper] {D5DEDD}Activation: /snh.", 0x01A0E9)

        sampRegisterChatCommand("snh", cmd_imgui)
        sampRegisterChatCommand("snh2", cmd_imgui2)

imgui.Process = false

imgui.SwitchContext()
themes.SwitchColorTheme(1)

            if CheckBox.v then
                if isKeyJustPressed(VK_J) and not sampIsCursorActive() then
                    sampSendChat('/help')
                end
            end


while true do
    wait(0)
end
end

function imgui.OnDrawFrame()
    if main_window_state.v then
        imgui.SetNextWindowSize(imgui.ImVec2(500, 600), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos(imgui.ImVec2((sw/2), sh/2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))

imgui.Begin("Sauntren Helper 1.0", main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
imgui.BeginChild("ChildWindow", imgui.ImVec2(484, 150), true)
imgui.Checkbox("Guns", CheckBox)
    imgui.SameLine()
imgui.Checkbox("SW ST", checked_test_2)
    imgui.EndChild()

imgui.InputText(u8'Введите текст:', text_buffer)
if imgui.Button(u8'Вывести в чат') then
    sampAddChatMessage(u8:decode(text_buffer.v), -1)
end


imgui.SetCursorPosY(575)
imgui.SetCursorPosX(455)
if imgui.Button(u8'Темы') then
    secondary_window_state.v = true
end


x, y, z = getCharCoordinates(PLAYER_PED)
imgui.SetCursorPosY(580)
imgui.SetCursorPosX(10)
imgui.Text(u8("Позиция игрока: X:" .. math.floor(x) .. " | Y: " .. math.floor(y) .. " | Z: " .. math.floor(z)))
imgui.End()
end

if main_window_state.v == false then
    imgui.Process = false
end

imgui.SetNextWindowSize(imgui.ImVec2(150, 205), imgui.Cond.FirstUseEver)
imgui.SetNextWindowPos(imgui.ImVec2((sw/2), sh/2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
if secondary_window_state.v then
    imgui.Begin(u8'Темы', secondary_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
    imgui.BeginChild("ChildWindow2", imgui.ImVec2(140, 175), true)
    for i, value in ipairs(themes.colorThemes) do
        if imgui.RadioButton(value, checked_radio, i) then
            themes.SwitchColorTheme(i)
        end
    end
    imgui.EndChild()
imgui.End()
end
end




function cmd_imgui(arg)
    main_window_state.v = not main_window_state.v
    imgui.Process = main_window_state.v
end

function cmd_imgui2(arg)
    secondary_window_state.v = not secondary_window_state.v
    imgui.Process = secondary_window_state.v
end

function apply_custom_style()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
end
apply_custom_style()
1656221871630.png


1656221944738.png


1656221952340.png


1656221961379.png


1656221969865.png


1656221975435.png

Следующий раз когда ты используешь пробелы, рекомендую использовать табуляцию при открытии файла в редакторе

Форматировал
Lua:
script_name("Sauntren Helper")
script_author("Seth Sauntren")
script_description("Helper for Arizona RP")

require "lib.moonloader"
local keys = require "vkeys"
local imgui = require "imgui"
local encoding = require "encoding"
local main_window_state = imgui.ImBool(false)
local secondary_window_state = imgui.ImBool(false)
local text_buffer = imgui.ImBuffer(256)
local checked_radio = imgui.ImInt(1)
local CheckBox = imgui.ImBool(true)
local checked_test_2 = imgui.ImBool(false)
local sw, sh = getScreenResolution()
local themes = import "resource/imgui_themes.lua"
local combo_select = imgui.ImInt(0)
encoding.default = "CP1251"
u8 = encoding.UTF8

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then
        return
    end
    while not isSampAvailable() do
        wait(100)
    end
    sampAddChatMessage("[SN Helper] {D5DEDD}Version: 1.0. | Author: Seth Sauntren.", 0x01A0E9)
    sampAddChatMessage("[SN Helper] {D5DEDD}Activation: /snh.", 0x01A0E9)

    sampRegisterChatCommand("snh", cmd_imgui)
    sampRegisterChatCommand("snh2", cmd_imgui2)

    imgui.Process = false

    imgui.SwitchContext()
    themes.SwitchColorTheme(1)

    if CheckBox.v then
        if isKeyJustPressed(VK_J) and not sampIsCursorActive() then
            sampSendChat("/help")
        end
    end

    while true do
        wait(0)
    end
end

function imgui.OnDrawFrame()
    if main_window_state.v then
        imgui.SetNextWindowSize(imgui.ImVec2(500, 600), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos(imgui.ImVec2((sw / 2), sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))

        imgui.Begin("Sauntren Helper 1.0", main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
        imgui.BeginChild("ChildWindow", imgui.ImVec2(484, 150), true)
        imgui.Checkbox("Guns", CheckBox)
        imgui.SameLine()
        imgui.Checkbox("SW ST", checked_test_2)
        imgui.EndChild()

        imgui.InputText(u8 "Введите текст:", text_buffer)
        if imgui.Button(u8 "Вывести в чат") then
            sampAddChatMessage(u8:decode(text_buffer.v), -1)
        end

        imgui.SetCursorPosY(575)
        imgui.SetCursorPosX(455)
        if imgui.Button(u8 "Темы") then
            secondary_window_state.v = true
        end

        x, y, z = getCharCoordinates(PLAYER_PED)
        imgui.SetCursorPosY(580)
        imgui.SetCursorPosX(10)
        imgui.Text(u8("Позиция игрока: X:" .. math.floor(x) .. " | Y: " .. math.floor(y) .. " | Z: " .. math.floor(z)))
        imgui.End()
    end

    if main_window_state.v == false then
        imgui.Process = false
    end

    imgui.SetNextWindowSize(imgui.ImVec2(150, 205), imgui.Cond.FirstUseEver)
    imgui.SetNextWindowPos(imgui.ImVec2((sw / 2), sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
    if secondary_window_state.v then
        imgui.Begin(u8 "Темы", secondary_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
        imgui.BeginChild("ChildWindow2", imgui.ImVec2(140, 175), true)
        for i, value in ipairs(themes.colorThemes) do
            if imgui.RadioButton(value, checked_radio, i) then
                themes.SwitchColorTheme(i)
            end
        end
        imgui.EndChild()
        imgui.End()
    end
end

function cmd_imgui(arg)
    main_window_state.v = not main_window_state.v
    imgui.Process = main_window_state.v
end

function cmd_imgui2(arg)
    secondary_window_state.v = not secondary_window_state.v
    imgui.Process = secondary_window_state.v
end

function apply_custom_style()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
end
apply_custom_style()
 
Последнее редактирование:
  • Нравится
Реакции: VRush

sauntren

Новичок
Автор темы
14
1
я не понимаю, что в скрипте не так. даже вставив тамбулированный код нужная функция не работает .
Код:
script_name("Sauntren Helper")
script_author("Seth Sauntren")
script_description("Helper for Arizona RP")

require "lib.moonloader"
local keys = require "vkeys"
local imgui = require "imgui"
local encoding = require "encoding"
local main_window_state = imgui.ImBool(false)
local secondary_window_state = imgui.ImBool(false)
local text_buffer = imgui.ImBuffer(256)
local checked_radio = imgui.ImInt(1)
local checked_test = imgui.ImBool(false)
local checked_test_2 = imgui.ImBool(false)
local sw, sh = getScreenResolution()
local themes = import "resource/imgui_themes.lua"
local combo_select = imgui.ImInt(0)
encoding.default = "CP1251"
u8 = encoding.UTF8

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then
        return
    end
    while not isSampAvailable() do
        wait(100)
    end
    sampAddChatMessage("[SN Helper] {D5DEDD}Version: 1.0. | Author: Seth Sauntren.", 0x01A0E9)
    sampAddChatMessage("[SN Helper] {D5DEDD}Activation: /snh.", 0x01A0E9)

    sampRegisterChatCommand("snh", cmd_imgui)
    sampRegisterChatCommand("snh2", cmd_imgui2)

    imgui.Process = false

    imgui.SwitchContext()
    themes.SwitchColorTheme(1)


    while true do
        wait(0)
    end
end

function imgui.OnDrawFrame()
    if main_window_state.v then
        imgui.SetNextWindowSize(imgui.ImVec2(500, 600), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos(imgui.ImVec2((sw / 2), sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))

        imgui.Begin("Sauntren Helper 1.0", main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
        imgui.BeginChild("ChildWindow", imgui.ImVec2(484, 150), true)
        imgui.Checkbox("Help", checked_test)
        imgui.Checkbox("SW ST", checked_test_2)
        imgui.EndChild()

        imgui.InputText(u8 "Введите текст:", text_buffer)
        if imgui.Button(u8 "Вывести в чат") then
            sampAddChatMessage(u8:decode(text_buffer.v), -1)
        end

        imgui.SetCursorPosY(575)
        imgui.SetCursorPosX(455)
        if imgui.Button(u8 "Темы") then
            secondary_window_state.v = true
        end

        x, y, z = getCharCoordinates(PLAYER_PED)
        imgui.SetCursorPosY(580)
        imgui.SetCursorPosX(10)
        imgui.Text(u8("Позиция игрока: X:" .. math.floor(x) .. " | Y: " .. math.floor(y) .. " | Z: " .. math.floor(z)))
        imgui.End()
    end

    if main_window_state.v == false then
        imgui.Process = false
    end
    

    imgui.SetNextWindowSize(imgui.ImVec2(150, 205), imgui.Cond.FirstUseEver)
    imgui.SetNextWindowPos(imgui.ImVec2((sw / 2), sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
    if secondary_window_state.v then
        imgui.Begin(u8 "Темы", secondary_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
        imgui.BeginChild("ChildWindow2", imgui.ImVec2(140, 175), true)
        for i, value in ipairs(themes.colorThemes) do
            if imgui.RadioButton(value, checked_radio, i) then
                themes.SwitchColorTheme(i)
            end
        end
        imgui.EndChild()
        imgui.End()
    end
end

function cmd_imgui(arg)
    main_window_state.v = not main_window_state.v
    imgui.Process = main_window_state.v
end

function cmd_imgui2(arg)
    secondary_window_state.v = not secondary_window_state.v
    imgui.Process = secondary_window_state.v
end

function apply_custom_style()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
end
apply_custom_style()

function cmd_check(arg)
    if checked_test.v then
        if isKeyJustPressed(VK_J) and not sampIsCursorActive() then
            sampSendChat("help")
        end
    end
end

111 - 117 строчки функции нужной, что я не так делаю ?
 

VRush

https://t.me/vrushscript
Проверенный
2,344
1,091
я не понимаю, что в скрипте не так. даже вставив тамбулированный код нужная функция не работает .
Код:
script_name("Sauntren Helper")
script_author("Seth Sauntren")
script_description("Helper for Arizona RP")

require "lib.moonloader"
local keys = require "vkeys"
local imgui = require "imgui"
local encoding = require "encoding"
local main_window_state = imgui.ImBool(false)
local secondary_window_state = imgui.ImBool(false)
local text_buffer = imgui.ImBuffer(256)
local checked_radio = imgui.ImInt(1)
local checked_test = imgui.ImBool(false)
local checked_test_2 = imgui.ImBool(false)
local sw, sh = getScreenResolution()
local themes = import "resource/imgui_themes.lua"
local combo_select = imgui.ImInt(0)
encoding.default = "CP1251"
u8 = encoding.UTF8

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then
        return
    end
    while not isSampAvailable() do
        wait(100)
    end
    sampAddChatMessage("[SN Helper] {D5DEDD}Version: 1.0. | Author: Seth Sauntren.", 0x01A0E9)
    sampAddChatMessage("[SN Helper] {D5DEDD}Activation: /snh.", 0x01A0E9)

    sampRegisterChatCommand("snh", cmd_imgui)
    sampRegisterChatCommand("snh2", cmd_imgui2)

    imgui.Process = false

    imgui.SwitchContext()
    themes.SwitchColorTheme(1)


    while true do
        wait(0)
    end
end

function imgui.OnDrawFrame()
    if main_window_state.v then
        imgui.SetNextWindowSize(imgui.ImVec2(500, 600), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos(imgui.ImVec2((sw / 2), sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))

        imgui.Begin("Sauntren Helper 1.0", main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
        imgui.BeginChild("ChildWindow", imgui.ImVec2(484, 150), true)
        imgui.Checkbox("Help", checked_test)
        imgui.Checkbox("SW ST", checked_test_2)
        imgui.EndChild()

        imgui.InputText(u8 "Введите текст:", text_buffer)
        if imgui.Button(u8 "Вывести в чат") then
            sampAddChatMessage(u8:decode(text_buffer.v), -1)
        end

        imgui.SetCursorPosY(575)
        imgui.SetCursorPosX(455)
        if imgui.Button(u8 "Темы") then
            secondary_window_state.v = true
        end

        x, y, z = getCharCoordinates(PLAYER_PED)
        imgui.SetCursorPosY(580)
        imgui.SetCursorPosX(10)
        imgui.Text(u8("Позиция игрока: X:" .. math.floor(x) .. " | Y: " .. math.floor(y) .. " | Z: " .. math.floor(z)))
        imgui.End()
    end

    if main_window_state.v == false then
        imgui.Process = false
    end
   

    imgui.SetNextWindowSize(imgui.ImVec2(150, 205), imgui.Cond.FirstUseEver)
    imgui.SetNextWindowPos(imgui.ImVec2((sw / 2), sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
    if secondary_window_state.v then
        imgui.Begin(u8 "Темы", secondary_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
        imgui.BeginChild("ChildWindow2", imgui.ImVec2(140, 175), true)
        for i, value in ipairs(themes.colorThemes) do
            if imgui.RadioButton(value, checked_radio, i) then
                themes.SwitchColorTheme(i)
            end
        end
        imgui.EndChild()
        imgui.End()
    end
end

function cmd_imgui(arg)
    main_window_state.v = not main_window_state.v
    imgui.Process = main_window_state.v
end

function cmd_imgui2(arg)
    secondary_window_state.v = not secondary_window_state.v
    imgui.Process = secondary_window_state.v
end

function apply_custom_style()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
end
apply_custom_style()

function cmd_check(arg)
    if checked_test.v then
        if isKeyJustPressed(VK_J) and not sampIsCursorActive() then
            sampSendChat("help")
        end
    end
end

111 - 117 строчки функции нужной, что я не так делаю ?
ты функцию не используешь.