Помощь исправить ошибку.

Yoda West

Новичок
Автор темы
11
0
Lua:
script_author("Yodo_West")
script_name("YodoWest")

require "lib.moonloader"
require "lib.sampfuncs"
local dlstatus = require('moonloader').download_status
local inicfg = require 'inicfg'
local keys = require "vkeys"
local imgui = require 'imgui'

local rkeys = require 'rkeys'
imgui.HotKey = require('imgui_addons').HotKey

local tLastKey = {}

local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local directIni = "moonloader\\settings.ini"

local mainIni = inicfg.load(nil, directIni)

if mainIni.hotkey == nil then -- если отсутствует секция hotkey в ини файле
    mainIni.hotkey = {
        bindClock = "[18,82]", -- alt + r
        bindPass = "[18,83]" -- alt + s
    }
end

local ActiveClockMenu = {
    v = decodeJson(mainIni.hotkey,bindClock)
}

local ActiveMaskMenu = {
    v = decodeJson(mainIni.hotkey,bindMask)
}

update_state = false

local script_vers = 1
local script_vers_text = "1.00"

local update_url = "https://raw.githubusercontent.com/YodoWest/YodoWest/main/update.ini" 
local update_path = getWorkingDirectory() .. "/update.ini"

local script_url = "https://github.com/YodoWest/YodoWest/blob/main/YodoWest.luac?raw=true" 
local script_path = thisScript().path

local tag = "{FFFF00}[YodoHelper] {FFFFFF}By {FFFF00}Yodo_West :)"

local main_window_state = imgui.ImBool(false)
local two_window_state = imgui.ImBool(false)

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampAddChatMessage("" .. tag, main_color)
    sampRegisterChatCommand("update", cmd_update)
    sampRegisterChatCommand("yodo", cmd_yodo)
    sampRegisterChatCommand("klad", cmd_klad)

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

    imgui.Process = false
        
    downloadUrlToFile(update_url, update_path, function(id, status)
        if status == dlstatus.STATUS_ENDDOWNLOADDATA then
            updateini = inicfg.load(nil, update_path)
            if tonumber(updateini.info.vers) > script_vers then
                sampAddChatMessage('Есть Обновление скрипта!', 0xFFFFFF)
                update_state = true
            end
            os.remove(update_path)
        end
    end)

    bindClock = rkeys.registerHotKey(ActiveClockMenu.v, true, clockFunc)
    bindMask = rkeys.registerHotKey(ActiveMaskMenu.v, true, maskFunc)

      while true do
        wait(0)

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

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

        if isCharOnAnyBike(playerPed) and isKeyCheckAvailable() and isKeyDown(0xA0) then
            if bike[getCarModel(storeCarCharIsInNoSave(playerPed))] then
                setGameKeyState(16, 255)
                wait(10)
                setGameKeyState(16, 0)
            elseif moto[getCarModel(storeCarCharIsInNoSave(playerPed))] then
                setGameKeyState(1, -128)
                wait(10)
                setGameKeyState(1, 0)
            end
        end
    end
end

function cmd_update(arg)
    sampShowDialog(1000, "Автообновление! v1.0", "{FFFFFF}Обновлений нету", "Закрыть", "", 0)
end

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

function clockFunc()
    sampSendChat("/armour")
end

function maskFunc()
    sampSendChat("/mask")
end

function imgui.OnDrawFrame()
  if main_window_state.v then
    local sw, sh = getScreenResolution()

    imgui.SetNextWindowSize(imgui.ImVec2(250, 250), imgui.Cond.FirstUseEver)
    imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))

    imgui.Begin(u8"[YodoHelper], Бинды", main_window_state, imgui.WindowFlags.NoColllapse)

    imgui.Text(u8"Надеть бронижелет. [1]")
    imgui.SameLine()
    if imgui.HotKey(##1, ActiveClockMenu, tLastKey, 100) then
        rkeys.chageHotKey(bindClock, ActiveClockMenu.v)
        sampAddChatMessage("Успешно! Старое значение: {F4A460}" .. table.concat(rkeys.getKeysName(tLastKey.v), "+") .. "{ffffff} | Новое: {F4A460}" .. table.concat(rkeys.getKeysName(ActiveClockMenu.v), "+"), -1)
        mainIni.HotKey.bindClock = encodeJson(ActiveClockMenu.v)
        inicfg.save(mainIni, directIni)
    end

    imgui.Text(u8"Надеть маску. [2]")
    imgui.SameLine()
    if imgui.HotKey(##2, ActiveMaskMenu, tLastKey, 100) then
        rkeys.chageHotKey(bindMask, ActiveMaskMenu.v)
        sampAddChatMessage("Успешно! Старое значение: {F4A460}" .. table.concat(rkeys.getKeysName(tLastKey.v), "+") .. "{ffffff} | Новое: {F4A460}" .. table.concat(rkeys.getKeysName(ActiveMaskMenu.v), "+"), -1)
        mainIni.HotKey.bindMask = encodeJson(ActiveMaskMenu.v)
        inicfg.save(mainIni, directIni)
    end
    imgui.End()
  end



    if two_window_state.v then
        local X, Y = getScreenResolution()
        imgui.SetNextWindowSize(imgui.ImVec2(250, 250), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos(imgui.ImVec2(X / 10, Y / 10), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.Begin(u8"[YodoHelper], Ответы на клады", two_window_state)
        imgui.Text(u8"Надеть бронижелет и маску. [3]")
        imgui.Text(u8"Включить фары. [0]")
        imgui.Text(u8"Открыть личный т|с. [L]")
        imgui.Text(u8"Вытащить|Вставить ключи. [K]")
        imgui.Text(u8"Ускорение на велике. [LSHIFT]")  -- что будет происходить если будет нажата кнопка
        imgui.End()
    end
end
 

Вложения

  • moonloader.log
    3.7 KB · Просмотры: 3

VRush

https://t.me/vrushscript
Проверенный
2,342
1,089
Lua:
script_author("Yodo_West")
script_name("YodoWest")

require "lib.moonloader"
require "lib.sampfuncs"
local dlstatus = require('moonloader').download_status
local inicfg = require 'inicfg'
local keys = require "vkeys"
local imgui = require 'imgui'

local rkeys = require 'rkeys'
imgui.HotKey = require('imgui_addons').HotKey

local tLastKey = {}

local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local directIni = "moonloader\\settings.ini"

local mainIni = inicfg.load(nil, directIni)

if mainIni.hotkey == nil then -- если отсутствует секция hotkey в ини файле
    mainIni.hotkey = {
        bindClock = "[18,82]", -- alt + r
        bindPass = "[18,83]" -- alt + s
    }
end

local ActiveClockMenu = {
    v = decodeJson(mainIni.hotkey,bindClock)
}

local ActiveMaskMenu = {
    v = decodeJson(mainIni.hotkey,bindMask)
}

update_state = false

local script_vers = 1
local script_vers_text = "1.00"

local update_url = "https://raw.githubusercontent.com/YodoWest/YodoWest/main/update.ini"
local update_path = getWorkingDirectory() .. "/update.ini"

local script_url = "https://github.com/YodoWest/YodoWest/blob/main/YodoWest.luac?raw=true"
local script_path = thisScript().path

local tag = "{FFFF00}[YodoHelper] {FFFFFF}By {FFFF00}Yodo_West :)"

local main_window_state = imgui.ImBool(false)
local two_window_state = imgui.ImBool(false)

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampAddChatMessage("" .. tag, main_color)
    sampRegisterChatCommand("update", cmd_update)
    sampRegisterChatCommand("yodo", cmd_yodo)
    sampRegisterChatCommand("klad", cmd_klad)

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

    imgui.Process = false
       
    downloadUrlToFile(update_url, update_path, function(id, status)
        if status == dlstatus.STATUS_ENDDOWNLOADDATA then
            updateini = inicfg.load(nil, update_path)
            if tonumber(updateini.info.vers) > script_vers then
                sampAddChatMessage('Есть Обновление скрипта!', 0xFFFFFF)
                update_state = true
            end
            os.remove(update_path)
        end
    end)

    bindClock = rkeys.registerHotKey(ActiveClockMenu.v, true, clockFunc)
    bindMask = rkeys.registerHotKey(ActiveMaskMenu.v, true, maskFunc)

      while true do
        wait(0)

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

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

        if isCharOnAnyBike(playerPed) and isKeyCheckAvailable() and isKeyDown(0xA0) then
            if bike[getCarModel(storeCarCharIsInNoSave(playerPed))] then
                setGameKeyState(16, 255)
                wait(10)
                setGameKeyState(16, 0)
            elseif moto[getCarModel(storeCarCharIsInNoSave(playerPed))] then
                setGameKeyState(1, -128)
                wait(10)
                setGameKeyState(1, 0)
            end
        end
    end
end

function cmd_update(arg)
    sampShowDialog(1000, "Автообновление! v1.0", "{FFFFFF}Обновлений нету", "Закрыть", "", 0)
end

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

function clockFunc()
    sampSendChat("/armour")
end

function maskFunc()
    sampSendChat("/mask")
end

function imgui.OnDrawFrame()
  if main_window_state.v then
    local sw, sh = getScreenResolution()

    imgui.SetNextWindowSize(imgui.ImVec2(250, 250), imgui.Cond.FirstUseEver)
    imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))

    imgui.Begin(u8"[YodoHelper], Бинды", main_window_state, imgui.WindowFlags.NoColllapse)

    imgui.Text(u8"Надеть бронижелет. [1]")
    imgui.SameLine()
    if imgui.HotKey(##1, ActiveClockMenu, tLastKey, 100) then
        rkeys.chageHotKey(bindClock, ActiveClockMenu.v)
        sampAddChatMessage("Успешно! Старое значение: {F4A460}" .. table.concat(rkeys.getKeysName(tLastKey.v), "+") .. "{ffffff} | Новое: {F4A460}" .. table.concat(rkeys.getKeysName(ActiveClockMenu.v), "+"), -1)
        mainIni.HotKey.bindClock = encodeJson(ActiveClockMenu.v)
        inicfg.save(mainIni, directIni)
    end

    imgui.Text(u8"Надеть маску. [2]")
    imgui.SameLine()
    if imgui.HotKey(##2, ActiveMaskMenu, tLastKey, 100) then
        rkeys.chageHotKey(bindMask, ActiveMaskMenu.v)
        sampAddChatMessage("Успешно! Старое значение: {F4A460}" .. table.concat(rkeys.getKeysName(tLastKey.v), "+") .. "{ffffff} | Новое: {F4A460}" .. table.concat(rkeys.getKeysName(ActiveMaskMenu.v), "+"), -1)
        mainIni.HotKey.bindMask = encodeJson(ActiveMaskMenu.v)
        inicfg.save(mainIni, directIni)
    end
    imgui.End()
  end



    if two_window_state.v then
        local X, Y = getScreenResolution()
        imgui.SetNextWindowSize(imgui.ImVec2(250, 250), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos(imgui.ImVec2(X / 10, Y / 10), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.Begin(u8"[YodoHelper], Ответы на клады", two_window_state)
        imgui.Text(u8"Надеть бронижелет и маску. [3]")
        imgui.Text(u8"Включить фары. [0]")
        imgui.Text(u8"Открыть личный т|с. [L]")
        imgui.Text(u8"Вытащить|Вставить ключи. [K]")
        imgui.Text(u8"Ускорение на велике. [LSHIFT]")  -- что будет происходить если будет нажата кнопка
        imgui.End()
    end
end
у тебя нет содержимого main ini
Не тот раздел