-1

所以代码错误是这样的:另外,lua代码用于FiveM编码,使用vRP作为主要框架。该错误对 vRP 上的函数提出上诉,而调用者是工件中的基本函数。

即便如此,这是触发错误的工件的代码

代码

错误的样子

local GetGameTimer = GetGameTimer
local _sbs = Citizen.SubmitBoundaryStart
local coresume, costatus = coroutine.resume, coroutine.status
local debug = debug
local coroutine_close = coroutine.close or (function(c) end) -- 5.3 compatibility
local hadThread = false
local curTime = 0

-- setup msgpack compat
msgpack.set_string('string_compat')
msgpack.set_integer('unsigned')
msgpack.set_array('without_hole')
msgpack.setoption('empty_table_as_array', true)

-- setup json compat
json.version = json._VERSION -- Version compatibility
json.setoption("empty_table_as_array", true)
json.setoption('with_hole', true)

-- temp
local _in = Citizen.InvokeNative

local function FormatStackTrace()
    return _in(`FORMAT_STACK_TRACE` & 0xFFFFFFFF, nil, 0, Citizen.ResultAsString())
end

local function ProfilerEnterScope(scopeName)
    return _in(`PROFILER_ENTER_SCOPE` & 0xFFFFFFFF, scopeName)
end

local function ProfilerExitScope()
    return _in(`PROFILER_EXIT_SCOPE` & 0xFFFFFFFF)
end

local newThreads = {}
local threads = setmetatable({}, {
    -- This circumvents undefined behaviour in "next" (and therefore "pairs")
    __newindex = newThreads,
    -- This is needed for CreateThreadNow to work correctly
    __index = newThreads
})

local boundaryIdx = 1
local runningThread

local function dummyUseBoundary(idx)
    return nil
end

local function getBoundaryFunc(bfn, bid)
    return function(fn, ...)
        local boundary = bid or (boundaryIdx + 1)
        boundaryIdx = boundaryIdx + 1
        
        bfn(boundary, coroutine.running())

        local wrap = function(...)
            dummyUseBoundary(boundary)
            
            local v = table.pack(fn(...))
            return table.unpack(v)
        end
        
        local v = table.pack(wrap(...))
        
        bfn(boundary, nil)
        
        return table.unpack(v)
    end
end

4

1 回答 1

0

您的代码的屏幕截图显示了两个调用getBoundaryFunc

runWithBoundaryStart = getBoundaryFunc(Citizen.SubmitBoundaryStart)
runWithBoundaryEnd = getBoundaryFunc(Citizen.SubmitBoundaryEnd)

为了fn成为 nil,必须在不证明第一个参数的情况下调用此函数中的任何一个。

  1. 找出是否有更多的电话getBoundaryFunc
  2. 找出它的返回值是否使用 nil 而不是预期的函数值作为第一个参数调用
  3. 解决这个问题
于 2021-03-29T14:43:34.170 回答