table overflow

weiSez

Участник
Автор темы
45
2
Версия MoonLoader
.026-beta
салам алейкум, скрипт крашит через некоторое время работы с ошибкой

Код:
[ML] (error) Helicopter-Camera: table overflow
stack traceback:
    [C]: in function 'cast'
    ...A San Andreas PD HELPER\moonloader\Helicopter-Camera.lua:1366: in function 'getCarID'
    ...A San Andreas PD HELPER\moonloader\Helicopter-Camera.lua:1076: in function <...A San Andreas PD HELPER\moonloader\Helicopter-Camera.lua:1052>
    [C]: in function 'wait'
    ...A San Andreas PD HELPER\moonloader\Helicopter-Camera.lua:1053: in function <...A San Andreas PD HELPER\moonloader\Helicopter-Camera.lua:1052>
[ML] (error) Helicopter-Camera: Script died due to an error. (0C51DCDC)

сама функция в которой происходит жёпа:
Lua:
function car()
    while true do wait(0)
        if active then
            sight_posX, sight_posY, sight_posZ = 0, 0, 0
            local pos, cam = {convertScreenCoordsToWorld3D(sw / 2, sh / 2, 700.0)}, getAC_PA()[1]
            local lres, res, c = copcall(processLineOfSight, cam[1], cam[2], cam[3], pos[1], pos[2], pos[3], true, true, true, true, true, true, true, true)

            if lres and res and (c.entityType == 2 or c.entityType == 3) then
                if c.entityType == 3 and getCharPointerHandle(c.entity) ~= PLAYER_PED or storeCarCharIsInNoSave(PLAYER_PED) ~= getVehiclePointerHandle(c.entity) then
                    sight_posX, sight_posY, sight_posZ = c.pos[1], c.pos[2], c.pos[3]

                    handle = c.entityType == 2 and getVehiclePointerHandle(c.entity) or getCharPointerHandle(c.entity)

                    id_model = c.entityType == 2 and getCarModel(handle) or getCharModel(handle)

                    name_model = c.entityType == 2 and CarModel(id_model) or NameModel(id_model)

                    local draw = c.entityType == 2 and {get_car_oordinates(handle)} or {get_char_oordinates(handle)}

                    local wposX, wposY = convert3DCoordsToScreen(draw[1], draw[2], draw[3])
                    drawIcon(1, 2, convertW(wposX).x, convertW(wposY).y, 42, 50, 0xDAFAFAFA)
                    if samp == 1 then
                        id_nickname = c.entityType == 2 and getPedID(getDriverOfCar(handle)) or getPedID(handle)

                        id_car = c.entityType == 2 and getCarID(handle) or -1
                    end
                    text_target = c.entityType == 2 and "ON VEHICLE" or "ON HUMAN"
                end
            else
                text_target = "NO TARGET"
            end

            if isKeyJustPressed(isKeys(config.keybind.active_fixview)) then
                if (text_target == "ON VEHICLE" or text_target == "ON HUMAN") then
                    handle_fixview, who = handle, text_target == "ON VEHICLE" and 2 or 3
                    active_fixview = not active_fixview
                    if not active_fixview then handle_fixview = -1 end
                else
                    active_fixview = false
                end
            end

            if active_fixview then
                local position, cam = (who == 2 and {get_car_oordinates(handle_fixview)} or who == 3 and {get_char_oordinates(handle_fixview)}), getAC_PA()[1]
                local dist = getDistanceBetweenCoords3d(cam[1], cam[2], cam[3], position[1], position[2], position[3])
                if dist <= (who == 2 and 300 or 200) then
                    pointCameraAtPoint(position[1], position[2], position[3], 2)
                else
                    warring_thread = lua_thread.create(function()
                        local timer = os.clock()
                        active_fixview = false
                        while true do wait(0)
                            drawIcon(1, 3, config.pos.info.x+15, config.pos.info.y+28, 35, 40, 0xDAFAFAFA)
                            setText(test_text3[1], RusToGame(u8:decode('~r~CONNECTION LOST')), config.pos.info.x+30, config.pos.info.y+24, 0.2, 1.1, 2, 1, '0xFFFFFFFF', 0.5, 0x15000000, 500, 500, false, true, true)
                            if os.clock() - timer > 2 or active_fixview then break end
                        end
                    end)
                end
            end
        end
    end
end

насколько я понимаю, краш скрипта идёт из-за того, что wait(0) во второй строке т.е. функция очень часто вызывается, но даже при 50 скрипт уже максимально некомфортно юзать.
сам скрипт: helicopter-camera
 
Решение
салам алейкум, скрипт крашит через некоторое время работы с ошибкой

Код:
[ML] (error) Helicopter-Camera: table overflow
stack traceback:
    [C]: in function 'cast'
    ...A San Andreas PD HELPER\moonloader\Helicopter-Camera.lua:1366: in function 'getCarID'
    ...A San Andreas PD HELPER\moonloader\Helicopter-Camera.lua:1076: in function <...A San Andreas PD HELPER\moonloader\Helicopter-Camera.lua:1052>
    [C]: in function 'wait'
    ...A San Andreas PD HELPER\moonloader\Helicopter-Camera.lua:1053: in function <...A San Andreas PD HELPER\moonloader\Helicopter-Camera.lua:1052>
[ML] (error) Helicopter-Camera: Script died due to an error. (0C51DCDC)

сама функция в которой происходит жёпа:
Lua:
function car()
    while true do wait(0)...

RedHolms

Известный
Проверенный
617
360
салам алейкум, скрипт крашит через некоторое время работы с ошибкой

Код:
[ML] (error) Helicopter-Camera: table overflow
stack traceback:
    [C]: in function 'cast'
    ...A San Andreas PD HELPER\moonloader\Helicopter-Camera.lua:1366: in function 'getCarID'
    ...A San Andreas PD HELPER\moonloader\Helicopter-Camera.lua:1076: in function <...A San Andreas PD HELPER\moonloader\Helicopter-Camera.lua:1052>
    [C]: in function 'wait'
    ...A San Andreas PD HELPER\moonloader\Helicopter-Camera.lua:1053: in function <...A San Andreas PD HELPER\moonloader\Helicopter-Camera.lua:1052>
[ML] (error) Helicopter-Camera: Script died due to an error. (0C51DCDC)

сама функция в которой происходит жёпа:
Lua:
function car()
    while true do wait(0)
        if active then
            sight_posX, sight_posY, sight_posZ = 0, 0, 0
            local pos, cam = {convertScreenCoordsToWorld3D(sw / 2, sh / 2, 700.0)}, getAC_PA()[1]
            local lres, res, c = copcall(processLineOfSight, cam[1], cam[2], cam[3], pos[1], pos[2], pos[3], true, true, true, true, true, true, true, true)

            if lres and res and (c.entityType == 2 or c.entityType == 3) then
                if c.entityType == 3 and getCharPointerHandle(c.entity) ~= PLAYER_PED or storeCarCharIsInNoSave(PLAYER_PED) ~= getVehiclePointerHandle(c.entity) then
                    sight_posX, sight_posY, sight_posZ = c.pos[1], c.pos[2], c.pos[3]

                    handle = c.entityType == 2 and getVehiclePointerHandle(c.entity) or getCharPointerHandle(c.entity)

                    id_model = c.entityType == 2 and getCarModel(handle) or getCharModel(handle)

                    name_model = c.entityType == 2 and CarModel(id_model) or NameModel(id_model)

                    local draw = c.entityType == 2 and {get_car_oordinates(handle)} or {get_char_oordinates(handle)}

                    local wposX, wposY = convert3DCoordsToScreen(draw[1], draw[2], draw[3])
                    drawIcon(1, 2, convertW(wposX).x, convertW(wposY).y, 42, 50, 0xDAFAFAFA)
                    if samp == 1 then
                        id_nickname = c.entityType == 2 and getPedID(getDriverOfCar(handle)) or getPedID(handle)

                        id_car = c.entityType == 2 and getCarID(handle) or -1
                    end
                    text_target = c.entityType == 2 and "ON VEHICLE" or "ON HUMAN"
                end
            else
                text_target = "NO TARGET"
            end

            if isKeyJustPressed(isKeys(config.keybind.active_fixview)) then
                if (text_target == "ON VEHICLE" or text_target == "ON HUMAN") then
                    handle_fixview, who = handle, text_target == "ON VEHICLE" and 2 or 3
                    active_fixview = not active_fixview
                    if not active_fixview then handle_fixview = -1 end
                else
                    active_fixview = false
                end
            end

            if active_fixview then
                local position, cam = (who == 2 and {get_car_oordinates(handle_fixview)} or who == 3 and {get_char_oordinates(handle_fixview)}), getAC_PA()[1]
                local dist = getDistanceBetweenCoords3d(cam[1], cam[2], cam[3], position[1], position[2], position[3])
                if dist <= (who == 2 and 300 or 200) then
                    pointCameraAtPoint(position[1], position[2], position[3], 2)
                else
                    warring_thread = lua_thread.create(function()
                        local timer = os.clock()
                        active_fixview = false
                        while true do wait(0)
                            drawIcon(1, 3, config.pos.info.x+15, config.pos.info.y+28, 35, 40, 0xDAFAFAFA)
                            setText(test_text3[1], RusToGame(u8:decode('~r~CONNECTION LOST')), config.pos.info.x+30, config.pos.info.y+24, 0.2, 1.1, 2, 1, '0xFFFFFFFF', 0.5, 0x15000000, 500, 500, false, true, true)
                            if os.clock() - timer > 2 or active_fixview then break end
                        end
                    end)
                end
            end
        end
    end
end

насколько я понимаю, краш скрипта идёт из-за того, что wait(0) во второй строке т.е. функция очень часто вызывается, но даже при 50 скрипт уже максимально некомфортно юзать.
сам скрипт: helicopter-camera
Переводчик.

Проблема в переполнении таблицы, значит, слишком много значений в одну таблицу запихал

Скинь либо полный код файлом, либо пометь, где какие строки (номера), а то непонятно где именно ошибка
 

weiSez

Участник
Автор темы
45
2
Переводчик.

Проблема в переполнении таблицы, значит, слишком много значений в одну таблицу запихал

Скинь либо полный код файлом, либо пометь, где какие строки (номера), а то непонятно где именно ошибка
я понимаю, что таблица переполняется, просто в скрипте на лазер для оружия используется вроде бы почти та же самая тема и там тоже wait(0), но всё работает стабильно без крашей за table overflow


лазер про который я говорил
 

Вложения

  • Helicopter-Camera.lua
    118.3 KB · Просмотры: 9
Последнее редактирование:

RedHolms

Известный
Проверенный
617
360
салам алейкум, скрипт крашит через некоторое время работы с ошибкой

Код:
[ML] (error) Helicopter-Camera: table overflow
stack traceback:
    [C]: in function 'cast'
    ...A San Andreas PD HELPER\moonloader\Helicopter-Camera.lua:1366: in function 'getCarID'
    ...A San Andreas PD HELPER\moonloader\Helicopter-Camera.lua:1076: in function <...A San Andreas PD HELPER\moonloader\Helicopter-Camera.lua:1052>
    [C]: in function 'wait'
    ...A San Andreas PD HELPER\moonloader\Helicopter-Camera.lua:1053: in function <...A San Andreas PD HELPER\moonloader\Helicopter-Camera.lua:1052>
[ML] (error) Helicopter-Camera: Script died due to an error. (0C51DCDC)

сама функция в которой происходит жёпа:
Lua:
function car()
    while true do wait(0)
        if active then
            sight_posX, sight_posY, sight_posZ = 0, 0, 0
            local pos, cam = {convertScreenCoordsToWorld3D(sw / 2, sh / 2, 700.0)}, getAC_PA()[1]
            local lres, res, c = copcall(processLineOfSight, cam[1], cam[2], cam[3], pos[1], pos[2], pos[3], true, true, true, true, true, true, true, true)

            if lres and res and (c.entityType == 2 or c.entityType == 3) then
                if c.entityType == 3 and getCharPointerHandle(c.entity) ~= PLAYER_PED or storeCarCharIsInNoSave(PLAYER_PED) ~= getVehiclePointerHandle(c.entity) then
                    sight_posX, sight_posY, sight_posZ = c.pos[1], c.pos[2], c.pos[3]

                    handle = c.entityType == 2 and getVehiclePointerHandle(c.entity) or getCharPointerHandle(c.entity)

                    id_model = c.entityType == 2 and getCarModel(handle) or getCharModel(handle)

                    name_model = c.entityType == 2 and CarModel(id_model) or NameModel(id_model)

                    local draw = c.entityType == 2 and {get_car_oordinates(handle)} or {get_char_oordinates(handle)}

                    local wposX, wposY = convert3DCoordsToScreen(draw[1], draw[2], draw[3])
                    drawIcon(1, 2, convertW(wposX).x, convertW(wposY).y, 42, 50, 0xDAFAFAFA)
                    if samp == 1 then
                        id_nickname = c.entityType == 2 and getPedID(getDriverOfCar(handle)) or getPedID(handle)

                        id_car = c.entityType == 2 and getCarID(handle) or -1
                    end
                    text_target = c.entityType == 2 and "ON VEHICLE" or "ON HUMAN"
                end
            else
                text_target = "NO TARGET"
            end

            if isKeyJustPressed(isKeys(config.keybind.active_fixview)) then
                if (text_target == "ON VEHICLE" or text_target == "ON HUMAN") then
                    handle_fixview, who = handle, text_target == "ON VEHICLE" and 2 or 3
                    active_fixview = not active_fixview
                    if not active_fixview then handle_fixview = -1 end
                else
                    active_fixview = false
                end
            end

            if active_fixview then
                local position, cam = (who == 2 and {get_car_oordinates(handle_fixview)} or who == 3 and {get_char_oordinates(handle_fixview)}), getAC_PA()[1]
                local dist = getDistanceBetweenCoords3d(cam[1], cam[2], cam[3], position[1], position[2], position[3])
                if dist <= (who == 2 and 300 or 200) then
                    pointCameraAtPoint(position[1], position[2], position[3], 2)
                else
                    warring_thread = lua_thread.create(function()
                        local timer = os.clock()
                        active_fixview = false
                        while true do wait(0)
                            drawIcon(1, 3, config.pos.info.x+15, config.pos.info.y+28, 35, 40, 0xDAFAFAFA)
                            setText(test_text3[1], RusToGame(u8:decode('~r~CONNECTION LOST')), config.pos.info.x+30, config.pos.info.y+24, 0.2, 1.1, 2, 1, '0xFFFFFFFF', 0.5, 0x15000000, 500, 500, false, true, true)
                            if os.clock() - timer > 2 or active_fixview then break end
                        end
                    end)
                end
            end
        end
    end
end

насколько я понимаю, краш скрипта идёт из-за того, что wait(0) во второй строке т.е. функция очень часто вызывается, но даже при 50 скрипт уже максимально некомфортно юзать.
сам скрипт: helicopter-camera
Проблема в FFI, попробуй создавать pointer функции заранее, и потом просто вызывай его, а не создавать каждый фрейм

Пример:
Lua:
local foo = nil

function main()
    -- ...
    foo = ffi.cast('unsigned short (__thiscall *)(uintptr_t, uintptr_t)', samp_handle() + (samp_v == 'R1' and 0x1B0A0 or 0x1E440))
    -- ...
end

-- где вызываешь функу
function use_foo(p)
    -- ...
    foo(vehpool, getCarPointer(p))
    -- ...
end
 
  • Нравится
Реакции: bottom_text и weiSez

RIPFY

Новичок
4
0
я понимаю, что таблица переполняется, просто в скрипте на лазер для оружия используется вроде бы почти та же самая тема и там тоже wait(0), но всё работает стабильно без крашей за table overflow


лазер про который я говорил
Скинь готовый скрипт пжлста, который с решением проблемы
 
  • Грустно
Реакции: vuyy

weiSez

Участник
Автор темы
45
2

Вложения

  • helicamfixed.7z
    194.6 KB · Просмотры: 1
  • Нравится
Реакции: RIPFY