Краш помогите

Сергей

Известный
Автор темы
150
9
Версия MoonLoader
.027.0-preview
Lua:
require"lib.sampfuncs"
require 'lib.moonloader'
local sampev = require 'lib.samp.events'
local key = require 'vkeys'
local imgui = require 'imgui' 
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local samp = require('samp.events')   
local chat = 0
local sampev = require 'lib.samp.events'

local chasi = imgui.ImBool(true)
local okno = imgui.ImBool(false)
local menu = imgui.ImBool(false)

function main()
  if not isSampLoaded() or not isSampfuncsLoaded() then return end
  while not isSampAvailable() do wait(100) end
  sampRegisterChatCommand("info2", function() okno.v = not okno.v end)
    sampRegisterChatCommand("infotest2", function() menu.v = not menu.v end)
  while true do
    wait(0)
    imgui.Process = chasi.v or okno.v or menu.v
    if not chasi.v or not okno.v or not menu.v then
      imgui.ShowCursor = false
    end
  end
end

function imgui.OnDrawFrame()
  if chasi.v then
    imgui.SetNextWindowPos(imgui.ImVec2(0,690), imgui.Cond.FirstUserEver)
    imgui.SetNextWindowSize(imgui.ImVec2(259, 80), imgui.Cond.FirstUseEver)
    imgui.Begin(u8'Информация', _, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
    imgui.ShowCursor = false
    imgui.Text(u8(string.format('Текущая дата: %s', os.date())))
    x, y , z = getCharCoordinates(PLAYER_PED)
    imgui.Text(u8("Позиция: X: " .. math.floor(x) .." | Y: " ..math.floor(y) .." | Z: " .. math.floor(z)))
    imgui.End()
  end
    if okno.v then
    imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
    imgui.SetNextWindowSize(imgui.ImVec2(560, 360), imgui.Cond.FirstUseEver)   
    imgui.Begin(u8'Таблица сокращений', okno)   
    imgui.ShowCursor = true
    imgui.Text(u8'Text')
    imgui.End()
    end
    if menu.v then
          imgui.LockPlayer = true
        imgui.SetNextWindowPos(imgui.ImVec2(x/2, y/2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(900, 500), imgui.Cond.FirstUseEver)
        imgui.Begin(u8('Text'), menu)
        imgui.BeginChild('left pane', imgui.ImVec2(150, 0), true)
        if not selected then selected = 1 end
        if imgui.Selectable(u8('1'), false) then selected = 1 end
        if imgui.Selectable(u8('2'), false) then selected = 2 end
        if imgui.Selectable(u8('3'), false) then selected = 3 end
        if imgui.Selectable(u8('4'), false) then selected = 4 end
        if imgui.Selectable(u8('5'), false) then selected = 5 end
        if imgui.Selectable(u8('6'), false) then selected = 6 end
        imgui.EndChild()
        imgui.SameLine()
        imgui.BeginGroup()
        if selected == 2 then
                    imgui.Text(u8'test')
                    imgui.Separator()
                    imgui.Text(u8'test')
                    end
        if selected == 3 then
                    imgui.Text(u8'Test')
                end
            end

        -- ...
        imgui.EndGroup()
        imgui.End()
    end
Подскажите из-за чего происходит краш?