Сохранение значения переменной после перезахода в игру

umeHHo oH

Участник
Автор темы
162
24
Помогите сделать это с этим бестолковым кодом
Код:
require "lib.moonloader"
local keys = require "vkeys"

local act = true

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
      while not isSampAvailable() do wait(100) end
      sampRegisterChatCommand("onsbiv", function() act = true
        printStringNow(string.format("~p~ SBIV - %s", "activated"), 1000)
      end)
      sampRegisterChatCommand("offsbiv", function() act = false
        printStringNow(string.format("~p~ SBIV - %s", "deactivated"), 1000)
      end)
      while true do
      wait(0)

    if act then
    if isKeyJustPressed(VK_1) and not sampIsChatInputActive() and not sampIsDialogActive() and not isPauseMenuActive() and not isSampfuncsConsoleActive() then sampSendChat("/usedrugs 3") wait(10) sampSendChat(" ") end

    if isKeyJustPressed(VK_2) and not sampIsChatInputActive() and not sampIsDialogActive() and not isPauseMenuActive() and not isSampfuncsConsoleActive() then sampSendChat("/usemed") wait(10) sampSendChat(" ") end
    
    else
    
    if isKeyJustPressed(VK_1) and not sampIsChatInputActive() and not sampIsDialogActive() and not isPauseMenuActive() and not isSampfuncsConsoleActive() then sampSendChat("/usedrugs 3") wait(10) end

    if isKeyJustPressed(VK_2) and not sampIsChatInputActive() and not sampIsDialogActive() and not isPauseMenuActive() and not isSampfuncsConsoleActive() then sampSendChat("/usemed") wait(10) end end

    if isKeyJustPressed(VK_L) and not sampIsChatInputActive() and not sampIsDialogActive() and not isPauseMenuActive() and not isSampfuncsConsoleActive() then sampSendChat("/lock") end

    if isKeyJustPressed(VK_CAPITAL) and not sampIsChatInputActive() and not sampIsDialogActive() and not isPauseMenuActive() and not isSampfuncsConsoleActive() then sampSendChat("/anims 1") wait(10) setVirtualKeyDown(VK_RETURN, true) wait(600) setVirtualKeyDown(VK_RETURN, false) end

end
end
 

ghostex

Активный
181
30
LUA:
require "lib.moonloader"
local keys = require "vkeys"
local imgui = require('imgui')
local act = true

local inicfg = require 'inicfg'
local directIni = 'sbiv.ini'
local ini = inicfg.load(inicfg.load({
    act = {
        act = true,
    },
}, directIni))

inicfg.save(ini, directIni)
local waitfrom = imgui.ImInt(ini.act1)
local window = imgui.ImBool(false)

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
      while not isSampAvailable() do wait(100) end
      sampRegisterChatCommand("onsbiv", function() act.v = true
        printStringNow(string.format("~p~ SBIV - %s", "activated"), 1000)
      end)
      sampRegisterChatCommand("offsbiv", function() act.v = false
        printStringNow(string.format("~p~ SBIV - %s", "deactivated"), 1000)
      end)
      while true do
      wait(0)

    if act.v == true then
     isKeyJustPressed(31) and not sampIsChatInputActive() and not sampIsDialogActive() and not isPauseMenuActive() and not isSampfuncsConsoleActive() then sampSendChat("/usedrugs 3") wait(10) sampSendChat(" ") or
    isKeyJustPressed(32) and not sampIsChatInputActive() and not sampIsDialogActive() and not isPauseMenuActive() and not isSampfuncsConsoleActive() then sampSendChat("/usemed") wait(10) sampSendChat(" ") then
    end
 
    else act.v == false then
    
    isKeyJustPressed(31) and not sampIsChatInputActive() and not sampIsDialogActive() and not isPauseMenuActive() and not isSampfuncsConsoleActive() then sampSendChat("/usedrugs 3") wait(10) or
    isKeyJustPressed(32) and not sampIsChatInputActive() and not sampIsDialogActive() and not isPauseMenuActive() and not isSampfuncsConsoleActive() then sampSendChat("/usemed") wait(10) or
    isKeyJustPressed(76) and not sampIsChatInputActive() and not sampIsDialogActive() and not isPauseMenuActive() and not isSampfuncsConsoleActive() then sampSendChat("/lock") or
    isKeyJustPressed(20) and not sampIsChatInputActive() and not sampIsDialogActive() and not isPauseMenuActive() and not isSampfuncsConsoleActive() then sampSendChat("/anims 1") wait(10) setVirtualKeyDown(13, true) wait(600) setVirtualKeyDown(13, false) then
    end
end
end

function save()
    ini.act = act.v
    inicfg.save(ini, directIni)
end