Сохранение в ini из InputText

Morse

Потрачен
Автор темы
436
70
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Версия MoonLoader
Другое
Как сохранить информацию в ini из поля ввода в Imgui ?
 

Morse

Потрачен
Автор темы
436
70
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.

Morse

Потрачен
Автор темы
436
70
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Первоначальное значение которое ты хочешь задать переменной
Code_6KGfnPlRBn.png

файл который ты скинул, как пофиксить вопросики?
 

Fott

Простреленный
3,431
2,267

Вложения

  • Uchim_Konfig.lua
    881 байт · Просмотры: 23
Последнее редактирование:

Morse

Потрачен
Автор темы
436
70
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.

Morse

Потрачен
Автор темы
436
70
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.

Morse

Потрачен
Автор темы
436
70
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.

Morse

Потрачен
Автор темы
436
70
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Покажи код скрипта..
Lua:
script_name("TPcordByMorse")
script_author("Morse")
script_description("Teleport to coordinates")
script_version("1.0")

require "lib.moonloader"
local keys = require "vkeys"
local imgui = require "imgui"
local encoding = require "encoding"
encoding.default = "CP1251"
u8 = encoding.UTF8

local main_color = 0xE6E6FA

local inicfg = require "inicfg"
local directIni = "moonloader\\coordinat.ini"
local mainIni = inicfg.load(nil, directIni)
local stateIni = inicfg.save(mainIni, directIni)

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

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

    sampAddChatMessage("[TPcordByMorse] Script is ready to using {FFDAB9} /tpcord", main_color)
    sampAddChatMessage("[TPcordByMorse] Script is ready to using {FFDAB9} /tpcord", main_color)
    sampAddChatMessage("[TPcordByMorse] Script is ready to using {FFDAB9} /tpcord", main_color)

    sampRegisterChatCommand("tpcord", cmd_tpcord)

    imgui.Process = false

    while true do
        wait(0)

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

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

function imgui.OnDrawFrame()
    local sw, sh = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(400, 95), imgui.Cond.FirstUseEver)
        imgui.GetStyle().WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
imgui.Begin("TPcordByMorse", main_window_state, imgui.WindowFlags.NoCollapse)
imgui.InputText(u8"Введите координаты", text_buffer)
if imgui.Button(u8"Телепорт") then
    sampAddChatMessage("Teleport...", main_color)
end
if imgui.Button(u8"Поставить метку", imgui.SameLine()) then
    sampAddChatMessage("Метка поставлена.", main_color)
end
if imgui.Button(u8"Сохранить координаты",  imgui.SameLine()) then
    mainIni.config.asd = u8:decode(text.v)
    inicfg.save(mainIni, directIni)
    sampAddChatMessage("Координаты сохранены.", main_color)
end
imgui.SetCursorPosX((imgui.GetWindowWidth() - 75) / 2)
imgui.Text("Script By Morse")
imgui.End()
end
 

Fott

Простреленный
3,431
2,267
Lua:
script_name("TPcordByMorse")
script_author("Morse")
script_description("Teleport to coordinates")
script_version("1.0")

require "lib.moonloader"
local keys = require "vkeys"
local imgui = require "imgui"
local encoding = require "encoding"
encoding.default = "CP1251"
u8 = encoding.UTF8

local main_color = 0xE6E6FA

local inicfg = require "inicfg"
local directIni = "moonloader\\coordinat.ini"
local mainIni = inicfg.load(nil, directIni)
local stateIni = inicfg.save(mainIni, directIni)

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

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

    sampAddChatMessage("[TPcordByMorse] Script is ready to using {FFDAB9} /tpcord", main_color)
    sampAddChatMessage("[TPcordByMorse] Script is ready to using {FFDAB9} /tpcord", main_color)
    sampAddChatMessage("[TPcordByMorse] Script is ready to using {FFDAB9} /tpcord", main_color)

    sampRegisterChatCommand("tpcord", cmd_tpcord)

    imgui.Process = false

    while true do
        wait(0)

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

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

function imgui.OnDrawFrame()
    local sw, sh = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(400, 95), imgui.Cond.FirstUseEver)
        imgui.GetStyle().WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
imgui.Begin("TPcordByMorse", main_window_state, imgui.WindowFlags.NoCollapse)
imgui.InputText(u8"Введите координаты", text_buffer)
if imgui.Button(u8"Телепорт") then
    sampAddChatMessage("Teleport...", main_color)
end
if imgui.Button(u8"Поставить метку", imgui.SameLine()) then
    sampAddChatMessage("Метка поставлена.", main_color)
end
if imgui.Button(u8"Сохранить координаты",  imgui.SameLine()) then
    mainIni.config.asd = u8:decode(text.v)
    inicfg.save(mainIni, directIni)
    sampAddChatMessage("Координаты сохранены.", main_color)
end
imgui.SetCursorPosX((imgui.GetWindowWidth() - 75) / 2)
imgui.Text("Script By Morse")
imgui.End()
end
И где ты у себя конфиг видишь?
 

Morse

Потрачен
Автор темы
436
70
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.

Fott

Простреленный
3,431
2,267
Код:
local inicfg = require "inicfg"
local directIni = "moonloader\\coordinat.ini"
local mainIni = inicfg.load(nil, directIni)
local stateIni = inicfg.save(mainIni, directIni)
Открой файл с объяснениями который я тебе скинул и на свой.
Если ты не понимаешь ничего и у тебя нету желания даже смотреть тогда удачи в просмотре видео