Краш после использования imgui

Thomasya

Известный
Автор темы
68
2
Версия SA-MP
  1. 0.3.7 (R1)
  2. 0.3.7-R2
  3. 0.3.7-R3
  4. 0.3.7-R4
  5. Любая
Приветствую происходит краш по срабатыванию команды. Прикрепляю moonloader.log и код скрипта.
Краш происходит когда ввожу команду /cmds
Сборка дапо 130к не уверен какая версия сампа
Lua:
script_name("SabinyMultiTool") -- название скрипта
script_author("Raffaello_Sabiny") -- автор скрипта
script_description("Активация /sinfo") -- описание скрипта
script_version("1")

require "lib.moonloader" -- подключение библиотеки
require "lib.sampfuncs"

local sampev = require 'lib.samp.events'
local imgui = require "imgui"
local vkeys = require "vkeys"
local mc = 0x5A90CE
local gc = 0x00FF00
local imgui = require "imgui" -- загружаем библиотеку
local encoding = require "encoding" -- загружаем библиотеку
encoding.default = "CP1251" -- указываем кодировку по умолчанию, она должна совпадать с кодировкой файла. CP1251 - это Windows-1251
u8 = encoding.UTF8 -- и создаём короткий псевдоним для кодировщика UTF-8
local test_text_buffer = imgui.ImBuffer(256)
local main_window_state = imgui.ImBool(false)
local two_window_state = imgui.ImBool(false)

local russian_characters = {
  [168] = "Ё", [184] = "ё", [192] = "А", [193] = "Б", [194] = "В", [195] = "Г", [196] = "Д", [197] = "Е", [198] = "Ж", [199] = "З", [200] = "И", [201] = "Й", [202] = "К", [203] = "Л", [204] = "М", [205] = "Н", [206] = "О", [207] = "П", [208] = "Р", [209] = "С", [210] = "Т", [211] = "У", [212] = "Ф", [213] = "Х", [214] = "Ц", [215] = "Ч", [216] = "Ш", [217] = "Щ", [218] = "Ъ", [219] = "Ы", [220] = "Ь", [221] = "Э", [222] = "Ю", [223] = "Я", [224] = "а", [225] = "б", [226] = "в", [227] = "г", [228] = "д", [229] = "е", [230] = "ж", [231] = "з", [232] = "и", [233] = "й", [234] = "к", [235] = "л", [236] = "м", [237] = "н", [238] = "о", [239] = "п", [240] = "р", [241] = "с", [242] = "т", [243] = "у", [244] = "ф", [245] = "х", [246] = "ц", [247] = "ч", [248] = "ш", [249] = "щ", [250] = "ъ", [251] = "ы", [252] = "ь", [253] = "э", [254] = "ю", [255] = "я",
}

-- Сюда добавлять названия для кнопок, продолжать можешь сколько угодно
local buttonName = {
  --------Бизы--------
  u8'1.Какой командой продать бизнес за мафию? - [Ответ: /givebiz ]',

}     

-- Сюда добавлять текст для диалога, продолжать можешь сколько угодно
local buttonText = {

"1.Какой командой продать бизнес за мафию? - [Ответ: /givebiz ]",

}

math.randomseed(os.time() - os.clock() * 1000)



function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end

    sampAddChatMessage("[SabinyMultiTool]:{FFFFFF} Успешно загружен.", gc)

    sampRegisterChatCommand("cmds", function() main_window_state.v = not main_window_state.v end) -- Команда /cmds
    sampRegisterChatCommand("sinfo", function() two_window_state.v = not two_window_state.v end) -- Команда /cinfo 


     while true do
    wait(0)

    local result, button, list, input = sampHasDialogRespond(557)
    if result then
      if button == 1 then
        if list == 0 then
          lua_thread.create(function(input)
            sampSendChat("")
          end, input)
        end
      end
    end
    imgui.Process = main_window_state.v or two_window_state.v
  end
end



function imgui.OnDrawFrame()
  if main_window_state.v then
    local sw, sh = getScreenResolution()
    imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
    imgui.SetNextWindowSize(imgui.ImVec2(750, 250), imgui.Cond.FirstUseEver)
    imgui.Begin("SabinyMultiTool", main_window_state, imgui.WindowFlags.NoResize)
    imgui.InputText("##search", searchButton)
    for i = 1, #buttonName do
      if searchButton.v == "" then
        if imgui.Button(buttonName[i], imgui.ImVec2(-0.1, 20) )then
          sampAddChatMessage(buttonText[i], mc)
        end
      elseif string.lower(buttonName[i]):find(searchButton.v) or string.upper(buttonName[i]):find(searchButton.v) or string.rlower(u8:decode(buttonName[i])):find(u8:decode(searchButton.v)) or string.rupper(u8:decode(buttonName[i])):find(u8:decode(searchButton.v)) then
        if imgui.Button(buttonName[i], imgui.ImVec2(-0.1, 20) )then
          sampAddChatMessage(buttonText[i], mc)
        end
      end
    end
    imgui.End()
  end
  if two_window_state.v then
        local sw, sh = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(500, 450), imgui.Cond.FirstUseEver)
        imgui.Begin("Sabiny efir", two_window_state, imgui.WindowFlags.NoResize)
        if imgui.Button(u8"СМИ ЛC") then
        lua_thread.create(function()
                                    
        end)
        end
        imgui.Text(u8"Для активации меню вводите /cmds")
        imgui.Text(u8"Для активации меню вводите /cmds")
        imgui.Text(u8"Для активации меню вводите /cmds")
        imgui.Text(u8"Для активации меню вводите /cmds")
        imgui.Separator()--------------------------------------------------------------------------------------------------------------
        if imgui.Text(u8"-               Автор Raffaello_Sabiny                 -", beginchild == 13) then beginchild = 13 end --
        imgui.Separator()--------------------------------------------------------------------------------------------------------------
        imgui.End()
    end
end

function string.rlower(s)
  s = s:lower()
  local strlen = s:len()
  if strlen == 0 then return s end
  s = s:lower()
  local output = ""
  for i = 1, strlen do
    local ch = s:byte(i)
    if ch >= 192 and ch <= 223 then
      output = output .. russian_characters[ch + 32]
    elseif ch == 168 then
      output = output .. russian_characters[184]
    else
      output = output .. string.char(ch)
    end
  end
  return output
end

function string.rupper(s)
  s = s:upper()
  local strlen = s:len()
  if strlen == 0 then return s end
  s = s:upper()
  local output = ""
  for i = 1, strlen do
    local ch = s:byte(i)
    if ch >= 224 and ch <= 255 then
      output = output .. russian_characters[ch - 32]
    elseif ch == 184 then
      output = output .. russian_characters[168]
    else
      output = output .. string.char(ch)
    end
  end
  return output
end
Вот moonloader.log
Lua:
[20:04:28.017853] (system)    Session started.
[20:04:28.019840] (debug)    Module handle: 6E650000

MoonLoader v.026.5-beta loaded.
Developers: FYP, hnnssy, EvgeN 1137

Copyright (c) 2016, BlastHack Team
https://www.blast.hk/moonloader/

[20:04:28.019840] (info)    Working directory: C:\Games\GTA 130K BY DAPO SHOW\moonloader
[20:04:28.019840] (debug)    FP Control: 0009001F
[20:04:28.019840] (debug)    Game: GTA SA 1.0.0.0 US
[20:04:28.019840] (system)    Installing pre-game hooks...
[20:04:28.029853] (system)    Hooks installed.
[20:04:29.068133] (debug)    Initializing opcode handler table
[20:04:29.069133] (debug)    package.path = C:\Games\GTA 130K BY DAPO SHOW\moonloader\lib\?.lua;C:\Games\GTA 130K BY DAPO SHOW\moonloader\lib\?\init.lua;C:\Games\GTA 130K BY DAPO SHOW\moonloader\?.lua;C:\Games\GTA 130K BY DAPO SHOW\moonloader\?\init.lua;.\?.lua;C:\Games\GTA 130K BY DAPO SHOW\moonloader\lib\?.luac;C:\Games\GTA 130K BY DAPO SHOW\moonloader\lib\?\init.luac;C:\Games\GTA 130K BY DAPO SHOW\moonloader\?.luac;C:\Games\GTA 130K BY DAPO SHOW\moonloader\?\init.luac;.\?.luac
[20:04:29.069133] (debug)    package.cpath = C:\Games\GTA 130K BY DAPO SHOW\moonloader\lib\?.dll;
[20:04:29.071133] (system)    Loading script 'C:\Games\GTA 130K BY DAPO SHOW\moonloader\Arizona Tools v1.1.lua'...
[20:04:29.071133] (debug)    New script: 07064F8C
[20:04:29.091139] (system)    Az Tools: Loaded successfully.
[20:04:29.091139] (system)    Loading script 'C:\Games\GTA 130K BY DAPO SHOW\moonloader\AutoReboot.lua'...
[20:04:29.091139] (debug)    New script: 07065424
[20:04:29.095134] (system)    ML-AutoReboot: Loaded successfully.
[20:04:29.095134] (system)    Loading script 'C:\Games\GTA 130K BY DAPO SHOW\moonloader\check-moonloader-updates.lua'...
[20:04:29.095134] (debug)    New script: 0706529C
[20:04:29.110140] (system)    Check MoonLoader Updates: Loaded successfully.
[20:04:29.110140] (system)    Loading script 'C:\Games\GTA 130K BY DAPO SHOW\moonloader\reload_all.lua'...
[20:04:29.111135] (debug)    New script: 070664FC
[20:04:29.117138] (system)    ML-ReloadAll: Loaded successfully.
[20:04:29.118140] (system)    Loading script 'C:\Games\GTA 130K BY DAPO SHOW\moonloader\Sabiny CNN.lua'...
[20:04:29.118140] (debug)    New script: 07065734
[20:04:29.149138] (system)    Sabiny CNN.lua: Loaded successfully.
[20:04:29.149138] (system)    Loading script 'C:\Games\GTA 130K BY DAPO SHOW\moonloader\SabinyMultiTool.lua'...
[20:04:29.149138] (debug)    New script: 070661EC
[20:04:29.193139] (system)    SabinyMultiTool: Loaded successfully.
[20:04:29.193139] (system)    Loading script 'C:\Games\GTA 130K BY DAPO SHOW\moonloader\setWeather&Time.lua'...
[20:04:29.193139] (debug)    New script: 070655AC
[20:04:29.196142] (system)    setWeather&Time: Loaded successfully.
[20:04:29.197139] (system)    Loading script 'C:\Games\GTA 130K BY DAPO SHOW\moonloader\SF Integration.lua'...
[20:04:29.197139] (debug)    New script: 070658BC
[20:04:29.204141] (system)    SF Integration: Loaded successfully.
[20:04:31.803306] (system)    Installing post-load hooks...
[20:04:31.805293] (system)    Hooks installed.
[20:04:54.823771] (system)    Unloading...
[20:04:54.823771] (system)    Az Tools: Script terminated. (07064F8C)
[20:04:54.825771] (system)    ML-AutoReboot: Script terminated. (07065424)
[20:04:54.826772] (system)    Check MoonLoader Updates: Script terminated. (0706529C)
[20:04:54.827771] (system)    ML-ReloadAll: Script terminated. (070664FC)
[20:04:54.827771] (system)    Sabiny CNN.lua: Script terminated. (07065734)
[20:04:54.830773] (system)    SabinyMultiTool: Script terminated. (070661EC)
[20:04:54.834774] (system)    setWeather&Time: Script terminated. (070655AC)
[20:04:54.835774] (system)    SF Integration: Script terminated. (070658BC)
[20:04:54.842774] (system)    Session terminated.