Lua inicfg

Jendosik

Участник
Автор темы
211
12
Версия MoonLoader
.026-beta
У меня есть код и нада зделать тип если я написал команду а ты скрипт роботает ищё раз а не роботает и после перезаходу сохранялось
Lua:
require "lib.moonloader"
local imgui = require 'imgui'
local encoding = require 'encoding'
local inicfg = require 'inicfg'
local samp = require 'samp.events'
local main_color = 0x02274D
local main_color2 = 0x50BD27
local main_color1 = 0xE60020
local main_color = 0x138D75
encoding.default = 'CP1251'
u8 = encoding.UTF8

local active = true

local directIni = 'moonloader//config//AutoLogin.ini'

local mainIni = inicfg.load({
    config =
    {
        activ = nil,
    }
}, 'AutoLogin.ini')
if not doesFileExist('moonloader/config/AutoLogin.ini') then inicfg.save(mainIni, 'AutoLogin.ini') end

function main()
    if not isSampAvailable() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampAddChatMessage('{00ffa1}[AutoLogin] by {0D6161}w{0D4B4B}1{0E3636}z{0F2121}3{100B0B}r ', -1)
    sampRegisterChatCommand('a', cmd_a)
     sampRegisterChatCommand('setpass', cmd_set)
    while true do
        wait(0)

        end
    end

    function cmd_a()
    active = not active
    if active then sampAddChatMessage('On', -1) else sampAddChatMessage('Off', -1)
    end
        
    end


    function cmd_set(arg)

        mainIni.config.activ = arg
    if inicfg.save(mainIni, directIni) and active then
        sampAddChatMessage('{02274D}[AutoLogin] Ваш пароль: {FFFFFF}'..arg, -1)
    end
    end



function samp.onShowDialog(id, s, t, b1, b2, t)
    if id == 0 and active then
    lua_thread.create(function()
        wait(100)
    sampSendDialogResponse(0, 1, 1, mainIni.config.activ)
    sampCloseCurrentDialogWithButton(0)

    end)
end
end
 
  • Нравится
Реакции: Liguer

Hatiko

Известный
Проверенный
1,471
612
Формируй вопрос более менее грамотно и нормально, хер поймёшь.
Я так понял нужно сохранять настройки перед выходом из игры.

Lua:
function onScriptTerminate(thisScript())
--Тут уже суй сохранение конфига
end
 

niki4

Участник
92
10
Формируй вопрос более менее грамотно и нормально, хер поймёшь.
Я так понял нужно сохранять настройки перед выходом из игры.

Lua:
function onScriptTerminate(thisScript())
--Тут уже суй сохранение конфига
end
Можно без thisScript()