Что не так с кодом?

Sanchez.

Известный
Автор темы
704
187
Lua:
script_name('UniversalHelperARZ')
script_author('Sanchez.')
script_description('Universal Helper for Arizona Role Play.')



local tag = "{DC143C}Universal{FFFFFF}Helper: "

local timestampcolor = 0x7B68EE



require "lib.moonloader"

local encoding = require 'encoding'

local inicfg = require 'inicfg'

local imgui = require 'imgui'

encoding.default = 'CP1251'

u8 = encoding.UTF8



local themes = import "resource/imgui_themes.lua"

local directIni = "moonloader\\settings.ini"

local mainIni = inicfg.load(nil, directIni)

if mainIni.hotkey == nil then

    mainIni.hotkey = {

        bindTime = "[18,82]",
        bindStyle = "[18,83]"
    }

end

local rkeys = require 'rkeys'

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

local tLastKeys = {}

local ActiveTimeMenu = {

    v = decodeJson(mainIni.hotkey.bindTime)

}

local ActiveStyleMenu = {

    v = decodeJson(mainIni.hotkey.bindStyle)

}

imgui.SwitchContext()

themes.SwitchColorTheme(2)

local main_window_state = imgui.ImBool(false)

local text_buffer = imgui.ImBuffer(256)


local sw, sh = getScreenResolution()

function main()

    if not isSampLoaded() or not isSampfuncsLoaded() then return end

    while not isSampAvailable() do wait(100) end

    sampRegisterChatCommand("arzhelper", cmd_arzhelper)

    sampAddChatMessage(tag .. "{7B68EE}Скрипт успешно запущен!", timestampcolor)
    wait(300)
    sampAddChatMessage(tag .. "{7B68EE}Автор скрипта: {FFFFFF}Sanchez.", timestampcolor)
    sampAddChatMessage(tag .. "{7B68EE}Меню хелпера: {FFFFFF}/arzhelper", timestampcolor)

    imgui.Process = false

    bindTime = rkeys.registerHotKey(ActiveTimeMenu.v, true, timeFunc)
    bindStyle = rkeys.registerHotKey(ActiveStyleMenu.v, true, styleFunc)

    while true do
        wait(0)

        if main_window_state.v == false then

            imgui.Process = false

        end

    end

end



function cmd_arzhelper()

    main_window_state.v = not main_window_state.v

    imgui.Process = main_window_state.v



end



function timeFunc()

    sampSendChat("/time")

end

function styleFunc()

    sampSendChat("/style")

end



function imgui.TextQuestion(label, description)

    imgui.TextDisabled(label)

    if imgui.IsItemHovered() then

        imgui.BeginTooltip()
            imgui.PushTextWrapPos(600)
                imgui.TextUnformatted(description)
            imgui.PopTextWrapPos()
        imgui.EndTooltip()
    end
end



function imgui.OnDrawFrame()

    imgui.SetNextWindowSize(imgui.ImVec2(700, 300), imgui.Cond.FirstUseEver)

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

    

    imgui.Begin(u8"Универсальный Helper для Arizona RP", main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)

    imgui.BeginChild('Select', imgui.ImVec2(200, -1), true)

    if imgui.Button(u8'Быстрые команды', imgui.ImVec2(190, 40), selected == 1) then selected = 1 end

    if imgui.Button(u8'Функции', imgui.ImVec2(190, 40), selected == 2) then selected = 2 end

    if imgui.Button(u8'Сокращенные команды', imgui.ImVec2(190, 40), selected == 3) then selected = 3 end

    if imgui.Button(u8'Информация о скрипте', imgui.ImVec2(190, 40), selected == 4) then selected = 4 end

    imgui.EndChild()

    imgui.SameLine()

    imgui.BeginChild("Main", imgui.ImVec2(-1, -1), true)

    if selected == 0 then

    elseif selected == 1 then

        -- Время --

        imgui.Text(u8'Посмотреть время:')

        imgui.SameLine()

        if imgui.HotKey("##1", ActiveTimeMenu, tLastKeys, 100) then

            rkeys.changeHotKey(bindTime, ActiveTimeMenu.v)

            sampAddChatMessage("Успешно!", -1)

            mainIni.hotkey.bindTime = encodeJson(ActiveTimeMenu.v)
            inicfg.save(mainIni, directIni)

        end

        -- Время --

        imgui.Separator()
        -- Стиль езды --
        imgui.Text(u8'Изменить стиль езды:')
        
        imgui.SameLine()

        if imgui.HotKey("##2", ActiveStyleMenu, tLastKeys, 100) then

            rkeys.changeHotKey(bindStyle, ActiveStyleMenu.v)

            sampAddChatMessage("Успешно!", -1)

            mainIni.hotkey.bindStyle = encodeJson(ActiveStyleMenu.v)
            inicfg.save(mainIni, directIni)

        end

        -- Стиль езды --
        imgui.Separator()

        imgui.Text(u8'Быстрый /stats:')

        

    elseif selected == 2 then imgui.Text(u8'Информация')

    elseif selected == 3 then imgui.Text(u8'Что-то ещё')

    elseif selected == 4 then imgui.Text(u8'Функции')

end

imgui.EndChild()

    imgui.End()

end

Вот такая ошибка:
UniversalHelperARZ: D:\GTA San Andreas\moonloader\lib\rkeys.lua:94: attempt to get length of field 'keys' (a nil value)
stack traceback:

Что делать?!?!
 

TokyoCola

Участник
63
4
Вот такая ошибка:
UniversalHelperARZ: D:\GTA San Andreas\moonloader\lib\rkeys.lua:94: attempt to get length of field 'keys' (a nil value)
stack traceback:
не только эта ошибка

01:31:49.164234] (error) UniversalHelperARZ: import 'resource/imgui_themes.lua' not found.
stack traceback:
[C]: in function 'import'
C:\Games\ARIZONA GAMES\bin\Arizona\moonloader\new 1.lua:27: in main chunk

01:32:53.180883] (error) UniversalHelperARZ: C:\Games\ARIZONA GAMES\bin\Arizona\moonloader\new 1.lua:33: attempt to index local 'mainIni' (a nil value)
stack traceback:
C:\Games\ARIZONA GAMES\bin\Arizona\moonloader\new 1.lua:33: in main chunk

начни с чего нибудь простого
 

Sanchez.

Известный
Автор темы
704
187
не только эта ошибка

01:31:49.164234] (error) UniversalHelperARZ: import 'resource/imgui_themes.lua' not found.
stack traceback:
[C]: in function 'import'
C:\Games\ARIZONA GAMES\bin\Arizona\moonloader\new 1.lua:27: in main chunk

01:32:53.180883] (error) UniversalHelperARZ: C:\Games\ARIZONA GAMES\bin\Arizona\moonloader\new 1.lua:33: attempt to index local 'mainIni' (a nil value)
stack traceback:
C:\Games\ARIZONA GAMES\bin\Arizona\moonloader\new 1.lua:33: in main chunk

начни с чего нибудь простого
Так с этим скриптом пойдет в папку resource imgui themes.lua
 

Neon3333

Известный
181
71
Lua:
script_name('UniversalHelperARZ')
script_author('Sanchez.')
script_description('Universal Helper for Arizona Role Play.')



local tag = "{DC143C}Universal{FFFFFF}Helper: "

local timestampcolor = 0x7B68EE



require "lib.moonloader"

local encoding = require 'encoding'

local inicfg = require 'inicfg'

local imgui = require 'imgui'

encoding.default = 'CP1251'

u8 = encoding.UTF8



local themes = import "resource/imgui_themes.lua"

local directIni = "moonloader\\settings.ini"

local mainIni = inicfg.load(nil, directIni)

if mainIni.hotkey == nil then

    mainIni.hotkey = {

        bindTime = "[18,82]",
        bindStyle = "[18,83]"
    }

end

local rkeys = require 'rkeys'

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

local tLastKeys = {}

local ActiveTimeMenu = {

    v = decodeJson(mainIni.hotkey.bindTime)

}

local ActiveStyleMenu = {

    v = decodeJson(mainIni.hotkey.bindStyle)

}

imgui.SwitchContext()

themes.SwitchColorTheme(2)

local main_window_state = imgui.ImBool(false)

local text_buffer = imgui.ImBuffer(256)


local sw, sh = getScreenResolution()

function main()

    if not isSampLoaded() or not isSampfuncsLoaded() then return end

    while not isSampAvailable() do wait(100) end

    sampRegisterChatCommand("arzhelper", cmd_arzhelper)

    sampAddChatMessage(tag .. "{7B68EE}Скрипт успешно запущен!", timestampcolor)
    wait(300)
    sampAddChatMessage(tag .. "{7B68EE}Автор скрипта: {FFFFFF}Sanchez.", timestampcolor)
    sampAddChatMessage(tag .. "{7B68EE}Меню хелпера: {FFFFFF}/arzhelper", timestampcolor)

    imgui.Process = false

    bindTime = rkeys.registerHotKey(ActiveTimeMenu.v, true, timeFunc)
    bindStyle = rkeys.registerHotKey(ActiveStyleMenu.v, true, styleFunc)

    while true do
        wait(0)

        if main_window_state.v == false then

            imgui.Process = false

        end

    end

end



function cmd_arzhelper()

    main_window_state.v = not main_window_state.v

    imgui.Process = main_window_state.v



end



function timeFunc()

    sampSendChat("/time")

end

function styleFunc()

    sampSendChat("/style")

end



function imgui.TextQuestion(label, description)

    imgui.TextDisabled(label)

    if imgui.IsItemHovered() then

        imgui.BeginTooltip()
            imgui.PushTextWrapPos(600)
                imgui.TextUnformatted(description)
            imgui.PopTextWrapPos()
        imgui.EndTooltip()
    end
end



function imgui.OnDrawFrame()

    imgui.SetNextWindowSize(imgui.ImVec2(700, 300), imgui.Cond.FirstUseEver)

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

   

    imgui.Begin(u8"Универсальный Helper для Arizona RP", main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)

    imgui.BeginChild('Select', imgui.ImVec2(200, -1), true)

    if imgui.Button(u8'Быстрые команды', imgui.ImVec2(190, 40), selected == 1) then selected = 1 end

    if imgui.Button(u8'Функции', imgui.ImVec2(190, 40), selected == 2) then selected = 2 end

    if imgui.Button(u8'Сокращенные команды', imgui.ImVec2(190, 40), selected == 3) then selected = 3 end

    if imgui.Button(u8'Информация о скрипте', imgui.ImVec2(190, 40), selected == 4) then selected = 4 end

    imgui.EndChild()

    imgui.SameLine()

    imgui.BeginChild("Main", imgui.ImVec2(-1, -1), true)

    if selected == 0 then

    elseif selected == 1 then

        -- Время --

        imgui.Text(u8'Посмотреть время:')

        imgui.SameLine()

        if imgui.HotKey("##1", ActiveTimeMenu, tLastKeys, 100) then

            rkeys.changeHotKey(bindTime, ActiveTimeMenu.v)

            sampAddChatMessage("Успешно!", -1)

            mainIni.hotkey.bindTime = encodeJson(ActiveTimeMenu.v)
            inicfg.save(mainIni, directIni)

        end

        -- Время --

        imgui.Separator()
        -- Стиль езды --
        imgui.Text(u8'Изменить стиль езды:')
       
        imgui.SameLine()

        if imgui.HotKey("##2", ActiveStyleMenu, tLastKeys, 100) then

            rkeys.changeHotKey(bindStyle, ActiveStyleMenu.v)

            sampAddChatMessage("Успешно!", -1)

            mainIni.hotkey.bindStyle = encodeJson(ActiveStyleMenu.v)
            inicfg.save(mainIni, directIni)

        end

        -- Стиль езды --
        imgui.Separator()

        imgui.Text(u8'Быстрый /stats:')

       

    elseif selected == 2 then imgui.Text(u8'Информация')

    elseif selected == 3 then imgui.Text(u8'Что-то ещё')

    elseif selected == 4 then imgui.Text(u8'Функции')

end

imgui.EndChild()

    imgui.End()

end

Вот такая ошибка:
UniversalHelperARZ: D:\GTA San Andreas\moonloader\lib\rkeys.lua:94: attempt to get length of field 'keys' (a nil value)
stack traceback:

Что делать?!?!
Снимать штаны и бегать. Или научиться читать трейсбэк, у тебя явно по ключу keys лежит nil и ты пытаешься получить его длину
 

Sanchez.

Известный
Автор темы
704
187
Снимать штаны и бегать. Или научиться читать трейсбэк, у тебя явно по ключу keys лежит nil и ты пытаешься получить его длину
я просто гайды смотрел TheChampGuess'a, я делал все также как и он
 

Shepard

Активный
459
88
У тебя куча ошибок в коде но не могу сказать каких именно, тебе придется переделывать код полностью т.к никто не захочет с таким кодом возиться
Ты лучше бы помог, а не дизморалил новичка
я просто гайды смотрел TheChampGuess'a, я делал все также как и он
@kalibyga , отпиши в вк, что-нибудь да и сделаем
 
  • Нравится
Реакции: Julimba и Sanchez.