- 706
- 188
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:
Что делать?!?!