краш игры

Lance_Sterling

Известный
Автор темы
802
284
Версия MoonLoader
.026-beta
кароче когда какой то игрок в сети то спустя какое то время игра нахуй крашится
Lua:
local checkerFrame = imgui.OnFrame(
    function() return mainIni.settings.show_checker and sampGetGamestate() == 3 and not isGamePaused() and not isPauseMenuActive() end,
    function(player)
        player.HideCursor = true
        local dl = imgui.GetBackgroundDrawList()
        dl:AddTextFontPtr(Font[20], 20, imgui.ImVec2(checkerPos[1].x - 1, checkerPos[1].y - 20 + 1), 0xFF000000, u8'Игроки онлайн:')
        dl:AddTextFontPtr(Font[20], 20, imgui.ImVec2(checkerPos[1].x + 1, checkerPos[1].y - 20 - 1), 0xFF000000, u8'Игроки онлайн:')
        dl:AddTextFontPtr(Font[20], 20, imgui.ImVec2(checkerPos[1].x - 1, checkerPos[1].y - 20 - 1), 0xFF000000, u8'Игроки онлайн:')
        dl:AddTextFontPtr(Font[20], 20, imgui.ImVec2(checkerPos[1].x + 1, checkerPos[1].y - 20 + 1), 0xFF000000, u8'Игроки онлайн:')
        dl:AddTextFontPtr(Font[20], 20, imgui.ImVec2(checkerPos[1].x, checkerPos[1].y - 20), 0xFFFF8C00, u8'Игроки онлайн:')
        for i = 0, sampGetMaxPlayerId(false) do
            if sampIsPlayerConnected(i) then
                for k, _ in ipairs(checker) do
                    if checker[k] then
                        local nick = sampGetPlayerNickname(i)
                        if checker[k].NICK == nick:gsub('%[.+%]', '') then
                            local result = true
                            for _, v in ipairs(checkerFriends) do
                                if v and checker[k] then
                                    if v:gsub('%[.+%] %[%d+%]', '') == checker[k].NICK then
                                        result = false
                                    end
                                end
                            end
                            if result and checker[k] then
                                table.insert(checkerPos, imgui.ImVec2(checkerPos[#checkerPos].x, checkerPos[#checkerPos].y + 20))
                                table.insert(checkerFriends, nick..' ['..i..']')
                            end
                        end
                    end
                end
            end
        end
        if not MOVE_CHECKER then
            for k, v in ipairs(checkerFriends) do
                dl:AddTextFontPtr(Font[20], 20, imgui.ImVec2(checkerPos[k].x - 1, checkerPos[k].y + 1), 0xFF000000, v)
                dl:AddTextFontPtr(Font[20], 20, imgui.ImVec2(checkerPos[k].x + 1, checkerPos[k].y - 1), 0xFF000000, v)
                dl:AddTextFontPtr(Font[20], 20, imgui.ImVec2(checkerPos[k].x - 1, checkerPos[k].y - 1), 0xFF000000, v)
                dl:AddTextFontPtr(Font[20], 20, imgui.ImVec2(checkerPos[k].x + 1, checkerPos[k].y + 1), 0xFF000000, v)
                dl:AddTextFontPtr(Font[20], 20, imgui.ImVec2(checkerPos[k].x, checkerPos[k].y), 0xFFFFFFFF, v)
                if sampGetPlayerNickname(v:match('.+%[.+%] %[(%d+)%]')) ~= v:gsub(' %[%d+%]', '') then
                    table.remove(checkerFriends, k)
                end
                if sampGetPlayerIdByNickname(v:gsub(' %[%d+%]', '')) == -1 then
                    table.remove(checkerFriends, k)
                end
            end
        end
    end
)

если шо я делаю nick:gsub('%[.+%]', '') потому что в сервере добавляется платформа, типо [PC] / [M]

@chapo

актуально
 
Последнее редактирование:

Lance_Sterling

Известный
Автор темы
802
284
одна из ошибок: 41 строка sampGetPlayerNickname принимает число аргументом, а ты передаёшь строку. Конвертируй результат string.match в число.
Lua:
local playerId = tonumber(v:match(".+%[.+%] %[(%d+)%]"))
sampGetPlayerNickname(playerId)
это верно) ща тестану