Неактуально фатальная ошибка

Lance_Sterling

Известный
Автор темы
801
279
Версия MoonLoader
.026-beta
дело в том, что массив выводит не те данные, должен вывести всех игроков с приписками [M] или [PC], с этим он справляется, но вот какая то хуйня
массив real_names в который я вставляю эти все ники решил выводить не все данные (ники по рандомному)
1678209414737.png


код:
Lua:
function shownicks(active)
    if active then
        AddChatMessage('Процесс начался!', 3)
        for k, v in ipairs(getAllChars()) do
            local result, id = sampGetPlayerIdByCharHandle(v)
            if result then
                local nick = sampGetPlayerNickname(id)
                if nick:find('%[PC%]') then
                    sampAddChatMessage(nick, -1)
                    table.insert(real_names, nick)
                    removePoopInNick(id, nick:gsub('%[PC%]', ''))
                elseif nick:find('%[M%]') then
                    sampAddChatMessage(nick, -1)
                    table.insert(real_names, nick)
                    removePoopInNick(id, nick:gsub('%[M%]', ''))
                end
                wait(0)
            end
        end
        AddChatMessage('Процесс завершён!', 3)
    else
        AddChatMessage('Процесс начался!', 3)
        for k, v in pairs(real_names) do
            wait(0)
            sampAddChatMessage(v, -1)
            if v:find('%[PC%]') then
                -- sampAddChatMessage(v:gsub('%[PC%]', ''), -1)
                removePoopInNick(sampGetPlayerIdByNickname(v:gsub('%[PC%]', '')), v)
                table.remove(real_names, k)
            elseif v:find('%[M%]') then
                -- sampAddChatMessage(v:gsub('%[M%]', ''), -1)
                removePoopInNick(sampGetPlayerIdByNickname(v:gsub('%[M%]', '')), v)
                table.remove(real_names, k)
            end
        end
        AddChatMessage('Процесс завершён!', 3)
    end
end

function sampGetPlayerIdByNickname(nick)
    local result, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
    if nick == sampGetPlayerNickname(id) then return id end
    for i = 0, sampGetMaxPlayerId(false) do
        if sampIsPlayerConnected(i) and sampGetPlayerNickname(i) == nick then return i end
    end
end

function samp.onPlayerStreamIn(playerId, team, model, position, rotation, color, fightingStyle)
    if tableOfNew.deleteplatforms.v then
        local streamName = sampGetPlayerNickname(playerId)
        if streamName:find('%[PC%]') then
            table.insert(real_names, streamName)
            streamName = streamName:gsub('%[PC%]', '')
            removePoopInNick(playerId, streamName)
        elseif streamName:find('%[M%]') then
            table.insert(real_names, streamName)
            streamName = streamName:gsub('%[M%]', '')
            removePoopInNick(playerId, streamName)
        end
    end
end
function samp.onPlayerStreamOut(playerId)
    if mainIni.settings.antigudelka then
        pldata[playerId].count = 0
        pldata[playerId].banned = false
    end
    if tableOfNew.deleteplatforms.v then
        local streamName = sampGetPlayerNickname(playerId)
        lua_thread.create(function()
            for i, v in ipairs(real_names) do
                wait(0)
                if v:gsub('%[PC%]', '') == streamName then
                    removePoopInNick(playerId, v)
                    table.remove(real_names, i)
                elseif v:gsub('%[M%]', '') == streamName then
                    removePoopInNick(playerId, v)
                    table.remove(real_names, i)
                end
            end
        end)
    end
end
function AddChatMessage(text, style)
    if style == 1 then
        local tag = '[Ghetto Helper]{FFFFFF}: '
        sampAddChatMessage(tag..text, 0xFFFF0F)
    elseif style == 2 then
        local tag = '[Ошибка] {FFFFFF}'
        sampAddChatMessage(tag..text, 0xF08080)
    elseif style == 3 then
        local tag = '[Информация] {FFFFFF}'
        sampAddChatMessage(tag..text, 0xA9A9A9)
    end
end

более наглядно -
1678210604121.png


по середине /test там то же самое но просто другой цикл
1678210703487.png


решил
Lua:
        for k,v in ipairs(real_names) do
            local nick = v:match('(.+_?.+)%[.+%]')
            if nick then
                removePoopInNick(sampGetPlayerIdByNickname(nick), v)
            end
        end
        real_names = {}
 
Последнее редактирование: