SAMP | Как сохранять IMGUI в .INI?

Ralph Carter

Новичок
Автор темы
10
1
Версия MoonLoader
Другое
Парни, как сделать так чтобы то что мы выбираем в IMGUI окне сохранялось после комбинации CTRL+R в конфиг скрипта?
 
Решение
Должно работать
Lua:
-- в начале
local abc = imgui.ImInt(mainIni.chtoto.chtoto)

-- в main()

while true do
    wait(0)
    if wasKeyPressed(VK_F12) then
        inicfg.save(mainIni, 'имя файла')
    end
end

-- в ondrawframe()

if imgui.Combo('##', abc, {u8"а", u8'б', u8'с'}, 3) then
    mainIni.chtoto.chtoto = abc.v
    sampAddChatMessage('Сохраненою', 0xffffff)
end

только это на клавшиу F12
Должно работать
Lua:
local abc = imgui.ImInt(mainIni.chtoto.chtoto)

while true do
    wait(0)
    if wasKeyPressed(VK_F12) then
        inicfg.save(mainIni, 'имя файла')
    end
end

if imgui.Combo('##', abc, {u8"а", u8'б', u8'с'}, 3) then
    mainIni.chtoto.chtoto = abc.v
    sampAddChatMessage('Сохраненою', 0xffffff)
end

askfmaskfaosflas

Потрачен
1,089
512
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Смотри. Вот пример
Lua:
if imgui.Checkbox(...) then
    saveconfig
end

..., saveconfig = заглушки, меняй их на функции из модуля inicfg
 

why ega

РП игрок
Модератор
2,545
2,236
Должно работать
Lua:
-- в начале
local abc = imgui.ImInt(mainIni.chtoto.chtoto)

-- в main()

while true do
    wait(0)
    if wasKeyPressed(VK_F12) then
        inicfg.save(mainIni, 'имя файла')
    end
end

-- в ondrawframe()

if imgui.Combo('##', abc, {u8"а", u8'б', u8'с'}, 3) then
    mainIni.chtoto.chtoto = abc.v
    sampAddChatMessage('Сохраненою', 0xffffff)
end

только это на клавшиу F12
Должно работать
Lua:
local abc = imgui.ImInt(mainIni.chtoto.chtoto)

while true do
    wait(0)
    if wasKeyPressed(VK_F12) then
        inicfg.save(mainIni, 'имя файла')
    end
end

if imgui.Combo('##', abc, {u8"а", u8'б', u8'с'}, 3) then
    mainIni.chtoto.chtoto = abc.v
    sampAddChatMessage('Сохраненою', 0xffffff)
end
 

Ralph Carter

Новичок
Автор темы
10
1
Что именно выбирали в окне?
Здравствуйте, извините за долгое отсутствие ответа.
Lua:
function imgui.OnDrawFrame()
    imgui.BeginChild("child", imgui.ImVec2(130, 500), true)
    if imgui.Button(u8"Основное", imgui.ImVec2(-1, 50)) then menu = 1 end
    if imgui.Button(u8"Информация", imgui.ImVec2(-1, 50)) then menu = 2 end
    if imgui.Button(u8"GameDay Project", imgui.ImVec2(-1, 50)) then menu = 3 end
    imgui.EndChild()
    imgui.SameLine()
    if menu == 1 then
        imgui.BeginChild("child2", imgui.ImVec2(800, 500), true)
        imgui.Text("sdghdfghfgjdjsdfklhsdfghsdflghsdkl;gj")
        !!! imgui.InputText(u8"Тест", text_buffer) !!!
        imgui.EndChild() 
    end
    imgui.SameLine()
    if menu == 2 then
        imgui.BeginChild("child2", imgui.ImVec2(800, 500), true)
        imgui.Text(u8"������������!")
        imgui.EndChild()
    end
    imgui.SameLine()
    if menu == 3 then
        imgui.BeginChild("child2", imgui.ImVec2(800, 500), true)
        imgui.Text("3")
        imgui.EndChild()
    end
end

Вот как сохранить то что я тремя "!" по сторонам

@egaa
 
Последнее редактирование:

why ega

РП игрок
Модератор
2,545
2,236
Lua:
-- в начале
local abc = imgui.ImBuffer(mainIni.chtoto.chtoto)

-- в main()

while true do
    wait(0)
    if wasKeyPressed(VK_F12) then
        inicfg.save(mainIni, 'имя файла')
    end
end

-- в ondrawframe()

if imgui.InputText('##', abc) then
    mainIni.chtoto.chtoto = abc.v
    sampAddChatMessage('Сохраненою', 0xffffff)
end
 
  • Нравится
Реакции: Ralph Carter

Ralph Carter

Новичок
Автор темы
10
1
Lua:
-- в начале
local abc = imgui.ImBuffer(mainIni.chtoto.chtoto)

-- в main()

while true do
    wait(0)
    if wasKeyPressed(VK_F12) then
        inicfg.save(mainIni, 'имя файла')
    end
end

-- в ondrawframe()

if imgui.InputText('##', abc) then
    mainIni.chtoto.chtoto = abc.v
    sampAddChatMessage('Сохраненою', 0xffffff)
end
Вопрос задаю с причиной незнания...)) local abc = imgui.ImBuffer(mainIni.chtoto.chtoto) "chtoto" у нас это что?
 

Ralph Carter

Новичок
Автор темы
10
1
Lua:
require "lib.moonloader"
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local inicfg = require 'inicfg'

local abc = imgui.ImBuffer(mainIni.config.name)
local directIni = 'moonloader\\PatrolHelper\\phsettings.ini'

local mainIni = inicfg.load(nil, directIni)
--local stateIni = inicfg.save(mainIni, directIni)

local tag = "{15A1EC}[PatrolTools] {FFFFFF}"
local label = 1
local main_color = 0x5A90CE
local main_color_text = "{5A90CE}"
local arr_str = {"LSPD", "SFPD", "LVPD"}

local main_window_state = imgui.ImBool(false)
local text_buffer = imgui.ImBuffer(256)

 -- for CHECKBOX
    local checked_text = imgui.ImBool(false)
    local checked_text_2 = imgui.ImBool(false)
--

-- for RADIO
    local checkedpd = imgui.ImInt(1)
--

-- for COMBO
    local combo_select = imgui.ImInt(0)
--

local sw, sh = getScreenResolution()

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

    sampRegisterChatCommand("search", c_search)
    sampRegisterChatCommand("cuff", c_cuff)
    sampRegisterChatCommand("uncuff", c_uncuff)
    sampRegisterChatCommand("уд", c_zeton)
    sampRegisterChatCommand("hold", c_hold)
    sampRegisterChatCommand("rn", c_nrp_r)
    sampRegisterChatCommand("fn", c_nrp_f)
    sampRegisterChatCommand("fixhold", c_fixhold)
    sampRegisterChatCommand("mask", c_mask)
    sampRegisterChatCommand("healme", c_healme)
    sampRegisterChatCommand("mir", c_mir)
    sampRegisterChatCommand("55", c_55)
    sampRegisterChatCommand("pt", c_menu)
    sampRegisterChatCommand("getname", c_getname)
    sampRegisterChatCommand("setname", c_setname)


    _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
    nick = sampGetPlayerNickname(id)

    imgui.Process = false

    thread = lua_thread.create_suspended(cv_search)


    if label == 1 then
    else
        sampAddChatMessage(tag .. "����������� ������.")
    end

--[[    sampAddChatMessage(tag .. "?????? ??????? ??????????.")
    sampAddChatMessage(tag .. "?????? ???????:????????????????")
--]]

    while true do
        wait(0)
    if wasKeyPressed(VK_F12) then
        inicfg.save(mainIni, 'phsettings.ini')
    end
        if main_window_state.v == false then
            imgui.Process = false
        end
    end
end

function c_search(arg)
    thread:run("search", arg)
end

function c_cuff(arg)
    thread:run("cuff", arg)
end

function c_uncuff(arg)
    thread:run("uncuff", arg)
end

function c_zeton(arg)
    thread:run("zeton", arg)
end

function c_hold(arg)
    thread:run("hold", arg)
end

function c_fixhold(arg)
    thread:run("fixhold", arg)
end

function c_mask()
    thread:run("mask", arg)
end

function c_healme()
    thread:run("healme", arg)
end

function c_mir()
    thread:run("mir", arg)
end

function c_55()
    thread:run("55", arg)
end

function cv_search(option, arg)
    if option == "search" then
        sampSendChat("/me ������ �������� � ������ ������ ��������� ��������, ����� �� �� ���� � ��������� ������� �������� ��������...")
        wait(1200)
        sampSendChat("/do ...����� ���� ���� �������� � ������� �� � ��������.")
        wait(1000)
        sampSendChat("/search " .. arg)
    end
    if option == "cuff" then
        sampSendChat("/me ���� � ����� ��������� � ����� �� �� ��������������")
        wait(1000)
        sampSendChat("/cuff " .. arg)
    end
    if option == "uncuff" then
        sampSendChat("/me ������ ���� � �������� � ��������� ��������� � ��������������")
        wait(1000)
        sampSendChat("/uncuff " .. arg)
    end
    if option == "zeton" then
        sampSendChat("/do � ������ ������� ����� ����� �������.")
        wait(1200)
        sampSendChat("/me ������ �� ������� ������� ������� � ������� ��� �������� ��������")
        wait(1200)
        sampSendChat("/do � �������� ��������: " .. arr_str[combo_select.v + 1] .. " | " .. text_buffer.v .. ".")
    end
    if option == "hold" then
        sampSendChat("/me ������ ���������� ���� ������� ���� �������������� � ���� ��� ����� �����")
        wait(1200)
        sampSendChat("/hold " .. arg)
    end
    if option == "fixhold" then
        sampSendChat("/uncuff " .. arg)
        sampSendChat("/cuff " .. arg)
        sampSendChat("/n �����")
    end
    if option == "mask" then
        sampSendChat("/me ������ �� �������� ����� � ����� � �� ������")
        wait(1000)
        sampSendChat("/mask")
    end
    if option == "healme" then
        sampSendChat("/me ������ �� �������� �������� � ������� � � ���")
        wait(1000)
        sampSendChat("/healme")
    end
    if option == "mir" then
        sampSendChat("�� ������ ����� ������� ��������, �� ��� �� �������, ����� � ����� ������������ ������ ��� � ����.")
        wait(1000)
        sampSendChat("��� ������� ����� �������������� ��� �������,")
        wait(1000)
        sampSendChat("���� �� �� ������ �������� ������ ��������, �� ����� ������������ ��� ������������.")
        wait(1000)
        sampSendChat("���� �� �� ��������� ���, �� ������ ����� ��������� ������� ����� ������.")
        wait(1000)
        sampSendChat("��� ��, �� ������ ����� �� ���� ���������� ������ ������������������ �� ����� ���� �����.")
        wait(1000)
        sampSendChat("��� ���� ���� �����")
    end
    if option == "55" then
        sampSendChat("/me ���� ������� � ����, ������� ��� � �������� ��������� �����")
        wait(500)
        sampSendChat("/m ��������! ���������� � �������, ����������!")
    end
end

function c_nrp_r(arg)
    sampSendChat("/r (( " .. arg .. " ))")
end

function c_nrp_f(arg)
    sampSendChat("/f (( " .. arg .. " ))")
end

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

function c_getname(arg)
    sampAddChatMessage(mainIni.config.name)
end

function c_setname(arg)
    mainIni.config.name = arg
    if inicfg.save(mainIni, directIni) then
        sampAddChatMessage("nice")
    end
end

function imgui.OnDrawFrame()
    imgui.BeginChild("child", imgui.ImVec2(130, 500), true)
    if imgui.Button(u8"Основное", imgui.ImVec2(-1, 50)) then menu = 1 end
    if imgui.Button(u8"Информация", imgui.ImVec2(-1, 50)) then menu = 2 end
    if imgui.Button(u8"GameDay Project", imgui.ImVec2(-1, 50)) then menu = 3 end
    imgui.EndChild()
    imgui.SameLine()
    if menu == 1 then
        imgui.BeginChild("child2", imgui.ImVec2(800, 500), true)
        imgui.Text("sdghdfghfgjdjsdfklhsdfghsdflghsdkl;gj")
        imgui.InputText(u8"Тест", text_buffer)
        imgui.EndChild()
    end
    imgui.SameLine()
    if menu == 2 then
        imgui.BeginChild("child2", imgui.ImVec2(800, 500), true)
        imgui.Text(u8"������������!")
        imgui.EndChild()
    end
    imgui.SameLine()
    if menu == 3 then
        imgui.BeginChild("child2", imgui.ImVec2(800, 500), true)
        imgui.Text("3")
        imgui.EndChild()
    end
end

На команды не обращай внимания.

Просто сохраняется в ini cfg ток через команды

Увидел в ютубе, переписал код и подумал что понял всё, а потом дошло что мне надо через меню сохранять
 

why ega

РП игрок
Модератор
2,545
2,236
Lua:
require "lib.moonloader"
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local inicfg = require 'inicfg'

local abc = imgui.ImBuffer(mainIni.config.name)
local directIni = 'moonloader\\PatrolHelper\\phsettings.ini'

local mainIni = inicfg.load(nil, directIni)
--local stateIni = inicfg.save(mainIni, directIni)

local tag = "{15A1EC}[PatrolTools] {FFFFFF}"
local label = 1
local main_color = 0x5A90CE
local main_color_text = "{5A90CE}"
local arr_str = {"LSPD", "SFPD", "LVPD"}

local main_window_state = imgui.ImBool(false)
local text_buffer = imgui.ImBuffer(256)

 -- for CHECKBOX
    local checked_text = imgui.ImBool(false)
    local checked_text_2 = imgui.ImBool(false)
--

-- for RADIO
    local checkedpd = imgui.ImInt(1)
--

-- for COMBO
    local combo_select = imgui.ImInt(0)
--

local sw, sh = getScreenResolution()

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

    sampRegisterChatCommand("search", c_search)
    sampRegisterChatCommand("cuff", c_cuff)
    sampRegisterChatCommand("uncuff", c_uncuff)
    sampRegisterChatCommand("уд", c_zeton)
    sampRegisterChatCommand("hold", c_hold)
    sampRegisterChatCommand("rn", c_nrp_r)
    sampRegisterChatCommand("fn", c_nrp_f)
    sampRegisterChatCommand("fixhold", c_fixhold)
    sampRegisterChatCommand("mask", c_mask)
    sampRegisterChatCommand("healme", c_healme)
    sampRegisterChatCommand("mir", c_mir)
    sampRegisterChatCommand("55", c_55)
    sampRegisterChatCommand("pt", c_menu)
    sampRegisterChatCommand("getname", c_getname)
    sampRegisterChatCommand("setname", c_setname)


    _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
    nick = sampGetPlayerNickname(id)

    imgui.Process = false

    thread = lua_thread.create_suspended(cv_search)


    if label == 1 then
    else
        sampAddChatMessage(tag .. "����������� ������.")
    end

--[[    sampAddChatMessage(tag .. "?????? ??????? ??????????.")
    sampAddChatMessage(tag .. "?????? ???????:????????????????")
--]]

    while true do
        wait(0)
    if wasKeyPressed(VK_F12) then
        inicfg.save(mainIni, 'phsettings.ini')
    end
        if main_window_state.v == false then
            imgui.Process = false
        end
    end
end

function c_search(arg)
    thread:run("search", arg)
end

function c_cuff(arg)
    thread:run("cuff", arg)
end

function c_uncuff(arg)
    thread:run("uncuff", arg)
end

function c_zeton(arg)
    thread:run("zeton", arg)
end

function c_hold(arg)
    thread:run("hold", arg)
end

function c_fixhold(arg)
    thread:run("fixhold", arg)
end

function c_mask()
    thread:run("mask", arg)
end

function c_healme()
    thread:run("healme", arg)
end

function c_mir()
    thread:run("mir", arg)
end

function c_55()
    thread:run("55", arg)
end

function cv_search(option, arg)
    if option == "search" then
        sampSendChat("/me ������ �������� � ������ ������ ��������� ��������, ����� �� �� ���� � ��������� ������� �������� ��������...")
        wait(1200)
        sampSendChat("/do ...����� ���� ���� �������� � ������� �� � ��������.")
        wait(1000)
        sampSendChat("/search " .. arg)
    end
    if option == "cuff" then
        sampSendChat("/me ���� � ����� ��������� � ����� �� �� ��������������")
        wait(1000)
        sampSendChat("/cuff " .. arg)
    end
    if option == "uncuff" then
        sampSendChat("/me ������ ���� � �������� � ��������� ��������� � ��������������")
        wait(1000)
        sampSendChat("/uncuff " .. arg)
    end
    if option == "zeton" then
        sampSendChat("/do � ������ ������� ����� ����� �������.")
        wait(1200)
        sampSendChat("/me ������ �� ������� ������� ������� � ������� ��� �������� ��������")
        wait(1200)
        sampSendChat("/do � �������� ��������: " .. arr_str[combo_select.v + 1] .. " | " .. text_buffer.v .. ".")
    end
    if option == "hold" then
        sampSendChat("/me ������ ���������� ���� ������� ���� �������������� � ���� ��� ����� �����")
        wait(1200)
        sampSendChat("/hold " .. arg)
    end
    if option == "fixhold" then
        sampSendChat("/uncuff " .. arg)
        sampSendChat("/cuff " .. arg)
        sampSendChat("/n �����")
    end
    if option == "mask" then
        sampSendChat("/me ������ �� �������� ����� � ����� � �� ������")
        wait(1000)
        sampSendChat("/mask")
    end
    if option == "healme" then
        sampSendChat("/me ������ �� �������� �������� � ������� � � ���")
        wait(1000)
        sampSendChat("/healme")
    end
    if option == "mir" then
        sampSendChat("�� ������ ����� ������� ��������, �� ��� �� �������, ����� � ����� ������������ ������ ��� � ����.")
        wait(1000)
        sampSendChat("��� ������� ����� �������������� ��� �������,")
        wait(1000)
        sampSendChat("���� �� �� ������ �������� ������ ��������, �� ����� ������������ ��� ������������.")
        wait(1000)
        sampSendChat("���� �� �� ��������� ���, �� ������ ����� ��������� ������� ����� ������.")
        wait(1000)
        sampSendChat("��� ��, �� ������ ����� �� ���� ���������� ������ ������������������ �� ����� ���� �����.")
        wait(1000)
        sampSendChat("��� ���� ���� �����")
    end
    if option == "55" then
        sampSendChat("/me ���� ������� � ����, ������� ��� � �������� ��������� �����")
        wait(500)
        sampSendChat("/m ��������! ���������� � �������, ����������!")
    end
end

function c_nrp_r(arg)
    sampSendChat("/r (( " .. arg .. " ))")
end

function c_nrp_f(arg)
    sampSendChat("/f (( " .. arg .. " ))")
end

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

function c_getname(arg)
    sampAddChatMessage(mainIni.config.name)
end

function c_setname(arg)
    mainIni.config.name = arg
    if inicfg.save(mainIni, directIni) then
        sampAddChatMessage("nice")
    end
end

function imgui.OnDrawFrame()
    imgui.BeginChild("child", imgui.ImVec2(130, 500), true)
    if imgui.Button(u8"Основное", imgui.ImVec2(-1, 50)) then menu = 1 end
    if imgui.Button(u8"Информация", imgui.ImVec2(-1, 50)) then menu = 2 end
    if imgui.Button(u8"GameDay Project", imgui.ImVec2(-1, 50)) then menu = 3 end
    imgui.EndChild()
    imgui.SameLine()
    if menu == 1 then
        imgui.BeginChild("child2", imgui.ImVec2(800, 500), true)
        imgui.Text("sdghdfghfgjdjsdfklhsdfghsdflghsdkl;gj")
        imgui.InputText(u8"Тест", text_buffer)
        imgui.EndChild()
    end
    imgui.SameLine()
    if menu == 2 then
        imgui.BeginChild("child2", imgui.ImVec2(800, 500), true)
        imgui.Text(u8"������������!")
        imgui.EndChild()
    end
    imgui.SameLine()
    if menu == 3 then
        imgui.BeginChild("child2", imgui.ImVec2(800, 500), true)
        imgui.Text("3")
        imgui.EndChild()
    end
end

На команды не обращай внимания.

Просто сохраняется в ini cfg ток через команды

Увидел в ютубе, переписал код и подумал что понял всё, а потом дошло что мне надо через меню сохранять
Тебе надо 226 строку сохранить?
 
  • Нравится
Реакции: Ralph Carter