Imgui(crash)

Lertex

Участник
Автор темы
30
0
Версия MoonLoader
.027.0-preview
Крашит когда /imgui ввожу.
Вот код краша::
[ML] (error) Notify.lua: ...R LAUNCHER\resources\projects\crmp\moonloader\Notify.lua:106: stack index 2, expected userdata, received string: value is not a valid userdata (bad argument into 'bool(const char*, ImValue<bool>*)')
stack traceback:
    [C]: in function 'Checkbox'
    ...R LAUNCHER\resources\projects\crmp\moonloader\Notify.lua:106: in function 'OnDrawFrame'
    ...AUNCHER\resources\projects\crmp\moonloader\lib\imgui.lua:1378: in function <...AUNCHER\resources\projects\crmp\moonloader\lib\imgui.lua:1367>
[ML] (error) Notify.lua: Script died due to an error. (45DFF854)
Вот сам луашник::
require "lib.moonloader"
local kays = require "vkeys"
local inicfg = require "inicfg"
local imgui = require "imgui"
local sampev = require "lib.samp.events"
local bNotf, notf = pcall(import, "imgui_notf.lua")
imgui.ToggleButton = require('imgui_addons').ToggleButton
one = 2
two = 1
three = 2
four = 2
five = 2
local font = renderCreateFont('Arial', 10, 5)
local ev = require 'lib.samp.events'
local inicfg = require 'inicfg'
local directIni = "help.ini"
local socket = require 'socket'
local mainIni = inicfg.load({
PARAMS = {
        check = "",
        Enable = false,
        
},
Time = {
                Time = false,
                IsEnabled1 = imgui.ImBool(false),
                x = 300,
                y = 300,
                color = "FFFFFF",
                msColor = "С3С3С3",
                fontsize = 12
            },
}, "help.ini")
if mainIni == nil then
    print('Не найден файл конфига, создаю.')
    if inicfg.save(mainIni, 'moonloader\\help.ini') then
        print('Файл был с настройками был создан, ошибок нет.')
        mainIni = inicfg.load({
            PARAMS = {
                    check = "",
                    Enable = imgui.ImBool(false)
            },
            Time = {
                Time = imgui.ImBool(false),
                IsEnabled1 = imgui.ImBool(false),
                x = 300,
                y = 300,
                color = "FFFFFF",
                msColor = "С3С3С3",
                fontsize = 12
            },
        }, "help.ini")
    end
end
local settings = mainIni.Pos
local stateIni = inicfg.save(mainIni, directIni)
local encoding = require "encoding"
encoding.default = 'CP1251'
u8 = encoding.UTF8
local main_window_state = imgui.ImBool(false)
local text_buffer = imgui.ImBuffer(256)
local fontsize = imgui.ImBuffer(256)
local Notify = mainIni.PARAMS.Enable
local Time = mainIni.Time.Time
local res, socket = pcall(require, 'socket')
local date_table = os.date("*t")
local ms = tostring(math.ceil(socket.gettime()*1000))
local ms = tonumber(string.sub(ms, #ms-2, #ms))
local hour, minute, second = date_table.hour, date_table.min, date_table.sec
local result = string.format("%02d:%02d:%02d{С3С3С3}.%03d", hour, minute, second, ms)
local hi = u8"Привет!"
local weekday = os.date("%w", datetime)
weekdays = {
    ["0"] = "воскресенье",
    ["1"] = "понедельник",
    ["2"] = "вторник",
    ["3"] = "среда",
    ["4"] = "четверг",
    ["5"] = "пятница",
    ["6"] = "суббота"
}
local month = os.date("%m", datetime)
months = {
    ["01"] = "Январь",
    ["02"] = "Февраль",
    ["03"] = "Март",
    ["04"] = "Апрель",
    ["05"] = "Май",
    ["06"] = "Июнь",
    ["07"] = "Июль",
    ["08"] = "Август",
    ["09"] = "Сентябрь",
    ["10"] = "Октябрь",
    ["11"] = "Ноябрь",
    ["12"] = "Декабрь"
}
IsEnabled1 = mainIni.Time.IsEnabled1
local IsEnabled = imgui.ImBool(true)

function imgui.OnDrawFrame()
    _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
    lvl = sampGetPlayerScore(select(2, sampGetPlayerIdByCharHandle(PLAYER_PED)))
    imgui.Begin(u8"Помощник by Lertex", main_window_state)
    imgui.Text(u8"Ваш id: "..id..u8"\nВаш уровень: "..lvl)
    imgui.Separator()
    imgui.Checkbox(u8"Время", IsEnabled1)
    imgui.Text(u8"Время с пк")
    imgui.SameLine(75)
    imgui.ToggleButton("Test##1", Time)
    imgui.SameLine(105)
    imgui.Text(u8"Время с сервера")
    imgui.InputText(u8"Размер шрифта", fontsize)
    mainIni.Time.fontsize = fontsize.v
    if imgui.Button(u8"Сохранить") then
        if tonumber(fontsize) then
            if inicfg.save(mainIni, directIni) then
                sampAddChatMessage("{6EF83C}Размер шрифта был изменен на "..mainIni.Time.fontsize, -1)
                imgui.Text(u8"Сохранено!")
            else
                sampAddChatMessage("{FF0000}Ошибка!", -1)
                imgui.Text(u8"Ошибка!")
            end
        else
            imgui.Text(u8"Введите размер цифрами!")
        end
    end
    imgui.Separator()
    if imgui.Checkbox(u8"Уведомления", IsEnabled) then
        mainIni.PARAMS.Enable = Notify
        if Notify then
            print(Notify)
            notf.addNotification("Уведомления включены by Lertex", 4, 4)
            if inicfg.save(mainIni, directIni) then
                sampAddChatMessage("Сохранено!", -1)
            else
                sampAddChatMessage("Ошибка!", -1)
            end
        else
            notf.addNotification("Уведомления выключены by Lertex", 4, 3)
            if inicfg.save(mainIni, directIni) then
                sampAddChatMessage("Сохранено!", -1)
            else
                sampAddChatMessage("Ошибка!", -1)
            end
        end
    end
    imgui.Separator()
    imgui.InputText(u8"Стоимость ремонта", text_buffer)
    mainIni.PARAMS.check = text_buffer.v
    if imgui.Button(u8"Сохранить") then
        if inicfg.save(mainIni, directIni) then
            sampAddChatMessage("{6EF83C}Цена была изменена на "..mainIni.PARAMS.check.." рублей", -1)
            imgui.Text(u8"Сохранено!")
        else
            sampAddChatMessage("{FF0000}Ошибка!", -1)
            imgui.Text(u8"Ошибка!")
        end
    end
    imgui.End()
end

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
    
    sampRegisterChatCommand("notifu", function()
        if Notify then
            print(Notify)
            notf.addNotification("Уведомления включены by Lertex", 4, 4)
        else
            notf.addNotification("Уведомления выключены by Lertex", 4, 3)
        end
    end)

    sampRegisterChatCommand("imgui", cmd_imgui)

    imgui.Process = false
    while true do
        wait(0)
        if bNotf then
            if IsEnabled1.v then
                mainIni.Time.IsEnabled1 = imgui.ImBool(true)
                if Time then
                    renderFontDrawText(font, os.date("Сегодня "..weekdays[weekday]..", %d число, месяц "..months[month].." %Y года\n%H часов %M минут %S секунд",os.time()), 25, 300, 0xFFFFFFFF, 0x90000000)
                else
                    renderFontDrawText(font, os.date("Сегодня "..weekdays[weekday]..", %d число, месяц "..months[month].." %Y года\n%H часов %M минут %S секунд",os.time()), 25, 300, 0xFFFFFFFF, 0x90000000)
                end
            else
                mainIni.Time.IsEnabled1 = imgui.ImBool(false)
            end
            if IsEnabled.v then
                Enable = false
                mainIni.PARAMS.Enable = imgui.ImBool(false)
                Notify = false
            else
                Enable = true
                mainIni.PARAMS.Enable = imgui.ImBool(true)
                Notify = true
            end
            if main_window_state.v == false then
                imgui.Process = false
            end
            _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
            nick = sampGetPlayerNickname(id)
            hp = getCharHealth(PLAYER_PED)
            lvl = sampGetPlayerScore(select(2, sampGetPlayerIdByCharHandle(PLAYER_PED)))
            if one == 2 then
                if lvl == 0 then
                    wait(0)
                else
                    if hour >= 5 and hour <= 10 then
                        hi = "Доброе утро, "
                    elseif hour >= 11 and hour <= 16 then
                        hi = "Добрый день, "
                    elseif hour >= 17 and hour <= 22 then
                        hi = "Добрый вечер, "
                    elseif hour >= 23 or hour <= 4 then
                        hi = "Доброй ночи, "
                    end
                    notf.addNotification(hi..""..nick.."\nВаш id: "..id.."\nВаш уровень: "..lvl.."\nПриятной игры!\nСкрипт by Lertex", 4, 4)
                    one = 3
                end
            end
            if Notify then
                if two == 1 then
                    if hp < 20 and hp > 1 then
                        notf.addNotification("У вас "..hp.." здоровья!\nПополните его", 4, 3)
                        two = 2
                    elseif hp < 50 and hp > 20 then
                        notf.addNotification("У вас "..hp.." здоровья!\nСоветуем пополнить здоровье", 4, 2)
                        two = 2
                    end
                else
                    two = 1
                end
                if isCharInAnyCar(PLAYER_PED) and one == 3 then
                    wait(250)
                    sampSendChat("/rem")
                    notf.addNotification("Пристегнулись!", 4, 4)
                    one = 4
                elseif not isCharInAnyCar(PLAYER_PED) and one == 4 then
                    one = 3
                end
            end
        end
    end
end

function ev.onServerMessage(color, text)
    lua_thread.create(function()
        _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
        nick = sampGetPlayerNickname(id)
        if Notify then
            if text:match("%a+_%a+ Предлагает починить Ваш транспорт за (%d+) руб") then
                local price = tonumber(text:match("%a+_%a+ Предлагает починить Ваш транспорт за (%d+) руб"))
                wait(100)
                mainIni.PARAMS.check = check
                if price < check then
                    sampSendChat("/yes")
                    wait(400)
                    setVirtualKeyDown(13, true)
                    wait(100)
                    setVirtualKeyDown(13, false)
                    wait(100)
                    sampAddChatMessage('{6EF83C}Успешно!', -1)
                else
                    sampAddChatMessage('{FF0000}Выбор за вами!', -1)
                end
            end

            if text:match("(.+)%["..id.."%] взял со склада (.+) %{FA5835%}%((.+) ед. материалов%)") then
                weapon = text:match("(.+)%["..id.."%] взял со склада (.+) %{FA5835%}%((.+) ед. материалов%)")
                notf.addNotification("Вы взяли со склада "..weapon.."\nМы напомним вам, когда можно будет взять ещё раз!", 4, 2)
                for i = 1, 300 do
                    wait(1000)
                    i = i + 1
                end
                if three == 1 then
                else
                    notf.addNotification("Можете взять оружие со склада!", 4, 4)
                    three = 1
                end
            end
        end
    end)
end

function setPrice(arg)
    if Notify then
        mainIni = inicfg.load(nil, directIni)
        sampAddChatMessage("{C3C3C3}Цена ремонта была - "..mainIni.PARAMS.check.." рублей", -1)
        mainIni.PARAMS.check = arg
        if inicfg.save(mainIni, directIni) then
            sampAddChatMessage("{6EF83C}Цена была изменена на "..mainIni.PARAMS.check.." рублей", -1)
        else
            sampAddChatMessage("{FF0000}Ошибка!", -1)
        end
    end
end

function cmd_imgui(arg)
    main_window_state.v = not main_window_state.v
    imgui.Process = main_window_state.v
end
 
  • Эм
Реакции: VanoKLR
Решение
Теперь это выдаёт:
Код:
[ML] (error) Notify.lua: ...R LAUNCHER\resources\projects\crmp\moonloader\Notify.lua:97: sol: no matching function call takes this number of arguments and the specified types
stack traceback:
    [C]: in function 'ImBool'
    ...R LAUNCHER\resources\projects\crmp\moonloader\Notify.lua:97: in main chunk
[ML] (error) Notify.lua: Script died due to an error. (45DFCB9C)
Лень заходить в гугл переводчик или что? ни один соответствующий вызов функции не принимает это количество аргументов и указанные типы

Lertex

Участник
Автор темы
30
0
В ини замени imgui.ImBool(false) на false
IsEnabled1 = mainIni.Time.IsEnabled1 замени на local IsEnabled1 = imgui.ImBool(mainIni.Time.IsEnabled1)
Теперь это выдаёт:
Код:
[ML] (error) Notify.lua: ...R LAUNCHER\resources\projects\crmp\moonloader\Notify.lua:97: sol: no matching function call takes this number of arguments and the specified types
stack traceback:
    [C]: in function 'ImBool'
    ...R LAUNCHER\resources\projects\crmp\moonloader\Notify.lua:97: in main chunk
[ML] (error) Notify.lua: Script died due to an error. (45DFCB9C)
 

Sadow

Известный
1,439
587
Теперь это выдаёт:
Код:
[ML] (error) Notify.lua: ...R LAUNCHER\resources\projects\crmp\moonloader\Notify.lua:97: sol: no matching function call takes this number of arguments and the specified types
stack traceback:
    [C]: in function 'ImBool'
    ...R LAUNCHER\resources\projects\crmp\moonloader\Notify.lua:97: in main chunk
[ML] (error) Notify.lua: Script died due to an error. (45DFCB9C)
Лень заходить в гугл переводчик или что? ни один соответствующий вызов функции не принимает это количество аргументов и указанные типы
 
  • Нравится
Реакции: riverya4life и YarikVL

sdfy

Известный
349
230
Теперь это выдаёт:
Код:
[ML] (error) Notify.lua: ...R LAUNCHER\resources\projects\crmp\moonloader\Notify.lua:97: sol: no matching function call takes this number of arguments and the specified types
stack traceback:
    [C]: in function 'ImBool'
    ...R LAUNCHER\resources\projects\crmp\moonloader\Notify.lua:97: in main chunk
[ML] (error) Notify.lua: Script died due to an error. (45DFCB9C)
файл конфига удали
 

Похожие темы

  1. Ответы
    16
    Просмотры
    2K