Lua Config

enyag

Известный
Автор темы
345
12
Версия MoonLoader
.026-beta
как сделать сохраниние цвета?
Lua:
-- main

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    inicfg.load(mainIni.config.textdraw1, directIni)
    inicfg.load(mainIni.config.textdraw2, directIni)
    sampTextdrawSetString(2, mainIni.config.textdraw1)
    sampTextdrawSetString(3, mainIni.config.textdraw2)
  
   -- imgui.OnDrawFrame
  
   if third_window_state.v then
            local sw, sh = getScreenResolution()
            imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.CondFirstUseEver, imgui.ImVec2(0.5, 0.5))
            imgui.SetNextWindowSize(imgui.ImVec2(1250, 343), imgui.Cond.FirstUseEver)
            imgui.Begin(u8"Смена лого и ника", third_window_state, imgui.WindowFlags.NoResize)
            if sampTextdrawIsExists(2) and sampTextdrawIsExists(3) then
                imgui.InputText(u8'Введите первый текстдрав(Pears)', pearsBufferText)
                imgui.InputText(u8'Введите второй текстдрав(Project)', projectBufferText)
                pears = pearsBufferText.v
                project = projectBufferText.v
                imgui.Text(u8'Сейчас вы можете выбрать подходящий цвет для вашего лого.\nОчень жаль что так мало цветов, но что есть, то есть :(')
                if imgui.CollapsingHeader(u8'Цвета первого текстдрава(Pears)', imgui.ImVec2(100, 50)) then
                    if imgui.ColorEdit3(u8'Выбор цвета 1 текстдрава', colortd) then
                        clrtd = join_argb(0, colortd.v[1] * 255, colortd.v[2] * 255, colortd.v[3] * 255)
                        local x1, y1 = sampTextdrawGetLetterSizeAndColor(2)
                        local newcolortd = '0xFF' .. ('%06X'):format(clrtd)
                        sampTextdrawSetLetterSizeAndColor(2, x1, y1, newcolortd)
                        sampTextdrawSetString(2, mainIni.config.textdraw1)
                    end
                end
                if imgui.CollapsingHeader(u8'Цвета второго текстдрава(Project)', imgui.ImVec2(100, 50)) then
                    imgui.SameLine()
                    imgui.TextQuestion(u8'Позволяет изменить цвет первого текстдрава')
                    if imgui.ColorEdit3(u8'Выбор цвета 2 текстдрава', colortd2) then
                        clrtd_2 = join_argb(0, colortd2.v[1] * 255, colortd2.v[2] * 255, colortd2.v[3] * 255)
                        local x2, y2 = sampTextdrawGetLetterSizeAndColor(3)
                        local newcolortd2 = '0xFF' .. ('%06X'):format(clrtd_2)
                        sampTextdrawSetLetterSizeAndColor(3, x2, y2, newcolortd2)
                        sampTextdrawSetString(3, mainIni.config.textdraw2)
                    end
                end
                if imgui.Button(u8'Сохранить', imgui.ImVec2(90, 25)) then
                    mainIni.config.textdraw1=pears
                    mainIni.config.textdraw2=project
                    inicfg.save(mainIni, directIni)
                        sampAddChatMessage("{349eeb}[Pears Script]: Успешно сохранено, первый текстдрав "..mainIni.config.textdraw1..". Второй текстдрав "..mainIni.config.textdraw2, -1)
                    end
                end
 

ufdhbi

Известный
Проверенный
1,455
861
как сделать сохраниние цвета?
Lua:
-- main

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    inicfg.load(mainIni.config.textdraw1, directIni)
    inicfg.load(mainIni.config.textdraw2, directIni)
    sampTextdrawSetString(2, mainIni.config.textdraw1)
    sampTextdrawSetString(3, mainIni.config.textdraw2)
 
   -- imgui.OnDrawFrame
 
   if third_window_state.v then
            local sw, sh = getScreenResolution()
            imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.CondFirstUseEver, imgui.ImVec2(0.5, 0.5))
            imgui.SetNextWindowSize(imgui.ImVec2(1250, 343), imgui.Cond.FirstUseEver)
            imgui.Begin(u8"Смена лого и ника", third_window_state, imgui.WindowFlags.NoResize)
            if sampTextdrawIsExists(2) and sampTextdrawIsExists(3) then
                imgui.InputText(u8'Введите первый текстдрав(Pears)', pearsBufferText)
                imgui.InputText(u8'Введите второй текстдрав(Project)', projectBufferText)
                pears = pearsBufferText.v
                project = projectBufferText.v
                imgui.Text(u8'Сейчас вы можете выбрать подходящий цвет для вашего лого.\nОчень жаль что так мало цветов, но что есть, то есть :(')
                if imgui.CollapsingHeader(u8'Цвета первого текстдрава(Pears)', imgui.ImVec2(100, 50)) then
                    if imgui.ColorEdit3(u8'Выбор цвета 1 текстдрава', colortd) then
                        clrtd = join_argb(0, colortd.v[1] * 255, colortd.v[2] * 255, colortd.v[3] * 255)
                        local x1, y1 = sampTextdrawGetLetterSizeAndColor(2)
                        local newcolortd = '0xFF' .. ('%06X'):format(clrtd)
                        sampTextdrawSetLetterSizeAndColor(2, x1, y1, newcolortd)
                        sampTextdrawSetString(2, mainIni.config.textdraw1)
                    end
                end
                if imgui.CollapsingHeader(u8'Цвета второго текстдрава(Project)', imgui.ImVec2(100, 50)) then
                    imgui.SameLine()
                    imgui.TextQuestion(u8'Позволяет изменить цвет первого текстдрава')
                    if imgui.ColorEdit3(u8'Выбор цвета 2 текстдрава', colortd2) then
                        clrtd_2 = join_argb(0, colortd2.v[1] * 255, colortd2.v[2] * 255, colortd2.v[3] * 255)
                        local x2, y2 = sampTextdrawGetLetterSizeAndColor(3)
                        local newcolortd2 = '0xFF' .. ('%06X'):format(clrtd_2)
                        sampTextdrawSetLetterSizeAndColor(3, x2, y2, newcolortd2)
                        sampTextdrawSetString(3, mainIni.config.textdraw2)
                    end
                end
                if imgui.Button(u8'Сохранить', imgui.ImVec2(90, 25)) then
                    mainIni.config.textdraw1=pears
                    mainIni.config.textdraw2=project
                    inicfg.save(mainIni, directIni)
                        sampAddChatMessage("{349eeb}[Pears Script]: Успешно сохранено, первый текстдрав "..mainIni.config.textdraw1..". Второй текстдрав "..mainIni.config.textdraw2, -1)
                    end
                end
mainIni.config.color1 = colortd:getU32() и тд
 

enyag

Известный
Автор темы
345
12
сделал вот так, не сохраняет
mainIni.config.color1 = colortd:getU32() и тд
Lua:
        -- main
        unction main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    inicfg.load(mainIni.config.textdraw1, directIni)
    inicfg.load(mainIni.config.textdraw2, directIni)
    inicfg.load(mainIni.config.color1, directIni)
    inicfg.load(mainIni.config.color2, directIni)
    sampTextdrawSetString(2, mainIni.config.textdraw1)
    sampTextdrawSetString(3, mainIni.config.textdraw2)
    sampTextdrawSetLetterSizeAndColor(3, x2, y2, mainIni.config.color1)
    sampTextdrawSetLetterSizeAndColor(2, x2, y2, mainIni.config.color2)
        
        -- imgui
        if third_window_state.v then
            local sw, sh = getScreenResolution()
            imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.CondFirstUseEver, imgui.ImVec2(0.5, 0.5))
            imgui.SetNextWindowSize(imgui.ImVec2(1250, 343), imgui.Cond.FirstUseEver)
            imgui.Begin(u8"Смена лого и ника", third_window_state, imgui.WindowFlags.NoResize)
            if sampTextdrawIsExists(2) and sampTextdrawIsExists(3) then
                imgui.InputText(u8'Введите первый текстдрав(Pears)', pearsBufferText)
                imgui.InputText(u8'Введите второй текстдрав(Project)', projectBufferText)
                pears = pearsBufferText.v
                project = projectBufferText.v
                imgui.Text(u8'Сейчас вы можете выбрать подходящий цвет для вашего лого.\nОчень жаль что так мало цветов, но что есть, то есть :(')
                if imgui.CollapsingHeader(u8'Цвета первого текстдрава(Pears)', imgui.ImVec2(100, 50)) then
                    if imgui.ColorEdit3(u8'Выбор цвета 1 текстдрава', colortd) then
                        clrtd = join_argb(0, colortd.v[1] * 255, colortd.v[2] * 255, colortd.v[3] * 255)
                        local x1, y1 = sampTextdrawGetLetterSizeAndColor(2)
                        local newcolortd = '0xFF' .. ('%06X'):format(clrtd)
                        sampTextdrawSetLetterSizeAndColor(2, x1, y1, newcolortd)
                        sampTextdrawSetString(2, mainIni.config.textdraw1)
                    end
                end
                if imgui.CollapsingHeader(u8'Цвета второго текстдрава(Project)', imgui.ImVec2(100, 50)) then
                    imgui.SameLine()
                    imgui.TextQuestion(u8'Позволяет изменить цвет первого текстдрава')
                    if imgui.ColorEdit3(u8'Выбор цвета 2 текстдрава', colortd2) then
                        clrtd_2 = join_argb(0, colortd2.v[1] * 255, colortd2.v[2] * 255, colortd2.v[3] * 255)
                        local x2, y2 = sampTextdrawGetLetterSizeAndColor(3)
                        local newcolortd2 = '0xFF' .. ('%06X'):format(clrtd_2)
                        sampTextdrawSetLetterSizeAndColor(3, x2, y2, newcolortd2)
                        sampTextdrawSetString(3, mainIni.config.textdraw2)
                    end
                end
                if imgui.Button(u8'Сохранить', imgui.ImVec2(90, 25)) then
                    mainIni.config.textdraw1=pears
                    mainIni.config.textdraw2=project
                    mainIni.config.color1 = colortd:getU32()
                    mainIni.config.color2 = colortd2:getU32()
                    inicfg.save(mainIni, directIni)
                        sampAddChatMessage("{349eeb}[Pears Script]: Успешно сохранено, первый текстдрав "..mainIni.config.textdraw1..". Второй текстдрав "..mainIni.config.textdraw2, -1)
                    end
                end