помогите с ошибкой table overflow

killerson

Участник
Автор темы
38
0
Версия MoonLoader
.027.0-preview
[19:28:46.616921] (error) noreload.lua: table overflow
stack traceback:
[C]: in function 'cast'
D:\GTA San Andreas Clear\moonloader\noreload.lua:31: in function 'reloadGun'
D:\GTA San Andreas Clear\moonloader\noreload.lua:11: in function <D:\GTA San Andreas Clear\moonloader\noreload.lua:4>
[19:28:46.616921] (error) noreload.lua: Script died due to an error. (0F3A6A1C)


noreload:
local ffi = require 'ffi'
local memory = require 'memory'

function main()
    while not isSampAvailable() do wait (100) end

    while true do
        wait(0)
        local ammo = getAmmoInClip()
        if ammo == 1 then
            reloadGun()
        end
    end
end

function getAmmoInClip() -- Функция Человечка.
    local pointer = getCharPointer(playerPed)
    local weapon = getCurrentCharWeapon(playerPed)
    local slot = getWeapontypeSlot(weapon)
    local cweapon = pointer + 0x5A0
    local current_cweapon = cweapon + slot * 0x1C
    return memory.getuint32(current_cweapon + 0x8)
end

function reloadGun()
    local CPed = getCharPointer(playerPed)
    local currentWeapon = getCurrentCharWeapon(playerPed)
    local weaponSlot = getWeapontypeSlot(currentWeapon)
    local CWeapon = CPed + 0x5A0
    local currentCWeapon = CWeapon + weaponSlot * 0x1C
    ffi.cast('void(__thiscall*)(void* CWeapon, void* CPed)', 0x73AEB0)(ffi.cast('void*', currentCWeapon), ffi.cast('void*', CPed))
end
 

chapo

чопа сребдс // @moujeek
Модератор
8,934
11,700
Lua:
local ffi = require 'ffi'
local memory = require 'memory'
local __reloadGun = ffi.cast('void(__thiscall*)(void* CWeapon, void* CPed)', 0x73AEB0);
function main()
    while not isSampAvailable() do wait (100) end

    while true do
        wait(0)
        local ammo = getAmmoInClip()
        if ammo == 1 then
            reloadGun()
        end
    end
end

function getAmmoInClip() -- Функция Человечка.
    local pointer = getCharPointer(playerPed)
    local weapon = getCurrentCharWeapon(playerPed)
    local slot = getWeapontypeSlot(weapon)
    local cweapon = pointer + 0x5A0
    local current_cweapon = cweapon + slot * 0x1C
    return memory.getuint32(current_cweapon + 0x8)
end

function reloadGun()
    local CPed = getCharPointer(playerPed)
    local currentWeapon = getCurrentCharWeapon(playerPed)
    local weaponSlot = getWeapontypeSlot(currentWeapon)
    local CWeapon = CPed + 0x5A0
    local currentCWeapon = CWeapon + weaponSlot * 0x1C
    __reloadGun(ffi.cast('void*', currentCWeapon), ffi.cast('void*', CPed))
end