lua скрипт работает только после перезагрузки через CTRL+R

Статус
В этой теме нельзя размещать новые ответы.

Tr1x2er

Участник
Автор темы
101
10
[17:27:04.373800] (error) ааа.lua: ...rple by pryanix\GTA Purple by pryanix\moonloader\ааа.lua:162: attempt to yield across C-call boundary
stack traceback:
[C]: in function 'wait'
...rple by pryanix\GTA Purple by pryanix\moonloader\ааа.lua:162: in function 'main'
...rple by pryanix\GTA Purple by pryanix\moonloader\ааа.lua:216: in main chunk
[17:27:04.373800] (error) ааа.lua: Script died due to an error. (05B558D4)
[17:27:07.897800] (system) Installing post-load hooks...
[17:27:07.897800] (system) Hooks installed.
Lua:
function main()
    while not isSampAvailable() do wait(0) end -- это 162 ошибка в коде
    sampRegisterChatCommand('spr', function()
        window[0] = not window[0]
    end)
end

function hook.onServerMessage(color, text)
    text = text:gsub("{%x%x%x%x%x%x}", "") 
    table.insert(chatLines, text)
    if spamActive[0] then
        lua_thread.create(processChatLines)
    end
end

function processChatLines()
    local command = u8:decode(ffi.string(commandText))
    for i = lastProcessedMessageId + 1, #chatLines do
        local text = chatLines[i]
        for _, word in ipairs(triggerWords) do
            local trigger = u8:decode(ffi.string(word))
            if string.find(text, trigger) then
                local playerName, playerId = extractPlayerInfo(text)
                if playerName and playerId then
                    updatePlayerLogs(playerName, playerId)
                    lua_thread.create(function()
                        local message = string.gsub(command, "{id}", tostring(playerId))
                        sampSendChat(message)
                        wait(spamDelay[0])
                    end)
                end
                break
            end
        end
        lastProcessedMessageId = i
    end
end

function extractPlayerInfo(text)
    local playerName = string.match(text, "^(%S+)")
    local playerId = string.match(text, "%[ID:(%d+)%]")
    return playerName, playerId
end

function updatePlayerLogs(playerName, playerId)
    local entry = playerName .. " " .. playerId
    if not playerLogEntries[entry] then
        playerLogEntries[entry] = true
        local currentLogs = ffi.string(playerLogs)
        local newLogEntry = string.format("%s\n", entry)
        local updatedLogs = currentLogs .. newLogEntry
        ffi.copy(playerLogs, updatedLogs)
    end
end

main() -- это 216 ошибка в коде
 
Последнее редактирование:
  • Bug
Реакции: MLycoris

VanoKLR

Известный
850
462
[17:27:04.373800] (error) ааа.lua: ...rple by pryanix\GTA Purple by pryanix\moonloader\ааа.lua:162: attempt to yield across C-call boundary
stack traceback:
[C]: in function 'wait'
...rple by pryanix\GTA Purple by pryanix\moonloader\ааа.lua:162: in function 'main'
...rple by pryanix\GTA Purple by pryanix\moonloader\ааа.lua:216: in main chunk
[17:27:04.373800] (error) ааа.lua: Script died due to an error. (05B558D4)
[17:27:07.897800] (system) Installing post-load hooks...
[17:27:07.897800] (system) Hooks installed.
Lua:
function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand('spr', function()
        window[0] = not window[0]
    end)
end

function hook.onServerMessage(color, text)
    text = text:gsub("{%x%x%x%x%x%x}", "")  -- Удаляем коды цветов
    table.insert(chatLines, text)
    if spamActive[0] then
        lua_thread.create(processChatLines)
    end
end

function processChatLines()
    local command = u8:decode(ffi.string(commandText))
    for i = lastProcessedMessageId + 1, #chatLines do
        local text = chatLines[i]
        for _, word in ipairs(triggerWords) do
            local trigger = u8:decode(ffi.string(word))
            if string.find(text, trigger) then
                local playerName, playerId = extractPlayerInfo(text)
                if playerName and playerId then
                    updatePlayerLogs(playerName, playerId)
                    lua_thread.create(function()
                        local message = string.gsub(command, "{id}", tostring(playerId))
                        sampSendChat(message)
                        wait(spamDelay[0])
                    end)
                end
                break
            end
        end
        lastProcessedMessageId = i
    end
end

function extractPlayerInfo(text)
    local playerName = string.match(text, "^(%S+)")
    local playerId = string.match(text, "%[ID:(%d+)%]")
    return playerName, playerId
end

function updatePlayerLogs(playerName, playerId)
    local entry = playerName .. " " .. playerId
    if not playerLogEntries[entry] then
        playerLogEntries[entry] = true
        local currentLogs = ffi.string(playerLogs)
        local newLogEntry = string.format("%s\n", entry)
        local updatedLogs = currentLogs .. newLogEntry
        ffi.copy(playerLogs, updatedLogs)
    end
end

main()
у тебя ошибка на 162 строчке, ты нам дал всего 56. Кидай весь код
 

Notepad++

Известный
281
157
[17:27:04.373800] (error) ааа.lua: ...rple by pryanix\GTA Purple by pryanix\moonloader\ааа.lua:162: attempt to yield across C-call boundary
stack traceback:
[C]: in function 'wait'
...rple by pryanix\GTA Purple by pryanix\moonloader\ааа.lua:162: in function 'main'
...rple by pryanix\GTA Purple by pryanix\moonloader\ааа.lua:216: in main chunk
[17:27:04.373800] (error) ааа.lua: Script died due to an error. (05B558D4)
[17:27:07.897800] (system) Installing post-load hooks...
[17:27:07.897800] (system) Hooks installed.
Lua:
function main()
    while not isSampAvailable() do wait(0) end -- это 162 ошибка в коде
    sampRegisterChatCommand('spr', function()
        window[0] = not window[0]
    end)
end

function hook.onServerMessage(color, text)
    text = text:gsub("{%x%x%x%x%x%x}", "")
    table.insert(chatLines, text)
    if spamActive[0] then
        lua_thread.create(processChatLines)
    end
end

function processChatLines()
    local command = u8:decode(ffi.string(commandText))
    for i = lastProcessedMessageId + 1, #chatLines do
        local text = chatLines[i]
        for _, word in ipairs(triggerWords) do
            local trigger = u8:decode(ffi.string(word))
            if string.find(text, trigger) then
                local playerName, playerId = extractPlayerInfo(text)
                if playerName and playerId then
                    updatePlayerLogs(playerName, playerId)
                    lua_thread.create(function()
                        local message = string.gsub(command, "{id}", tostring(playerId))
                        sampSendChat(message)
                        wait(spamDelay[0])
                    end)
                end
                break
            end
        end
        lastProcessedMessageId = i
    end
end

function extractPlayerInfo(text)
    local playerName = string.match(text, "^(%S+)")
    local playerId = string.match(text, "%[ID:(%d+)%]")
    return playerName, playerId
end

function updatePlayerLogs(playerName, playerId)
    local entry = playerName .. " " .. playerId
    if not playerLogEntries[entry] then
        playerLogEntries[entry] = true
        local currentLogs = ffi.string(playerLogs)
        local newLogEntry = string.format("%s\n", entry)
        local updatedLogs = currentLogs .. newLogEntry
        ffi.copy(playerLogs, updatedLogs)
    end
end

main() -- это 216 ошибка в коде
Зачем тебе вызов функции main, если она сама запускается
 
  • Нравится
Реакции: Tr1x2er и newkode299
Статус
В этой теме нельзя размещать новые ответы.