Ошибка, помогите её исправить

турбодизельный унитаз2012

Участник
Автор темы
127
9
Версия MoonLoader
.026-beta
Привет всем.
Делаю ЧС для смс.
Столкнулся с проблемой, не работает скрипт.
Что делать?

Lua:
require('lib.moonloader')
local event = require 'lib.samp.events'
local imgui = require 'mimgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local ffi = require('ffi')
local renderWindow = imgui.new.bool(false)
local text = imgui.new.char[256]()


local blnicks = file


imgui.OnInitialize(function()
    imgui.GetIO().IniFilename = nil
end)
local file = getWorkingDirectory()..'\\config\\sbl.json'
local nicknames = {}
function json(filePath)
    local f = {}

    function f:read()
        local f = io.open(filePath, "r+")
        local jsonInString = f:read("*a")
        f:close()
        local jsonTable = decodeJson(jsonInString)
        return jsonTable
    end

    function f:write(t)
        f = io.open(filePath, "w")
        f:write(encodeJson(t))
        f:flush()
        f:close()
    end

    return f
end
local newFrame = imgui.OnFrame(
    function() return renderWindow[0] end,
    function(player)
        local resX, resY = getScreenResolution()
        local sizeX, sizeY = 300, 300
        imgui.SetNextWindowPos(imgui.ImVec2(resX / 2, resY / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(sizeX, sizeY), imgui.Cond.FirstUseEver)
        if imgui.Begin(u8'Чёрный список входящих SMS', renderWindow) then
            for i, nickname in ipairs(nicknames) do
                imgui.Text(u8(i .. '.' .. nickname))
                imgui.SameLine()
                if imgui.Button(u8'удалить##' .. i) then
                    table.remove(nicknames, i)
                    json(file):write(nicknames)
                end
            end
            imgui.InputText('', text, ffi.sizeof(text))
            if imgui.Button(u8'Добавить в список') then
                table.insert(nicknames, u8:decode(ffi.string(text)))
                ffi.fill(text, ffi.sizeof(text), 0)
                json(file):write(nicknames)
            end
            imgui.End()
        end
    end
)

function main()
    while not isSampAvailable() do wait(0) end
    if doesFileExist(file) then
        nicknames = json(file):read()
    end
    sampRegisterChatCommand('sbl', function()
        renderWindow[0] = not renderWindow[0]
    end)
    wait(-1)
end

function event.onServerMessage(color, text)
    local nick, id = text:match(':SMS%: .* %| Отправитель%: (%w+_%w+)%[(%d+)%]')
    return false
    if nick and id then
        for _, v in pairs(blnicks) do
            if nick == v then
                lua_thread.create(function()
                wait(150)
                sampSendChat('/sms '..id..' Вы находитесь в чёрном списке SMS у данного человека. Будьте добры, не пишите сюда.')
                end)
            end
        end
    end
end
 

kyrtion

Известный
661
242
1714248626343.png