крашит скрипт mimgui

Kir

Участник
Автор темы
49
3
Версия MoonLoader
Другое
Сам код:
Код:
local imgui = require 'mimgui'
local ffi = require 'ffi'
local encoding = require 'encoding'
encoding.default = 'CP1251'
local u8 = encoding.UTF8

local window = imgui.new.bool(true)

imgui.OnInitialize(function()
    imgui.GetIO().IniFilename = nil
end)

local active = imgui.new.bool(false)

imgui.OnFrame
    (function() return true end,
    function(this)
        local size, res = imgui.ImVec2(450, 250),
        imgui.ImVec2(getScreenResolution())
        imgui.SetNextWindowSize(size, imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos(imgui.ImVec2(res.x / 2, res.y / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        if(imgui.Begin('GameSense', window, imgui.WindowFlags.NoCollapse)) then
            if (imgui.Button(u8'Клавиатура', imgui.ImVec2(200, 100))) then
                sampAddChatMessage('Нет блять мышка', -1)
            end
            if imgui.Checkbox(u8'Ragebot', active) then
                sampAddChatMessage('Ragebot ' .. (active[0] and 'on' or 'off'), -1)
            end
            imgui.InputText(u8'Текст', text, ffi.sizeof(text))
            if (imgui.Button(u8'Добавить текст в чат')) then
                sampAddChatMessage(u8:decode(ffi.string(text), -1))
            end
        end
        imgui.End()
end)

function main()
    while not isSampAvailable() do wait(0) end

    while true do
        wait(500)
        if (active[0]) then
            sampAddChatMessage(u8:decode(ffi.string(text)), -1)
        end
    end
end
А вот что пишет в консоли:
console:
[ML] (error) musicbot.lua: C:\Users\alesh\Desktop\white gta\moonloader\musicbot.lua:29: bad argument #1 to 'sizeof' (C type expected, got nil)
 

Kir

Участник
Автор темы
49
3
Может потому что у тебя даже переменной text нет
1703319563613.png
 

ChromiusJ

PARΛDIGM ΛSS
Друг
4,909
3,197

Kir

Участник
Автор темы
49
3
Для слепых ещё покажи
В скрипте она у тебя никак не инициализирована,и инпут не знает к чему обращаться
Lua:
local text = imgui.new.char[256]() -- в самое начало
так блять я у чапо полностью код переписывал, у него всё работало без инициализации переменной text