-1

So the code error is this: Also, the lua code is used for FiveM-coding, using vRP as main framework. The error appeals a function that is on vRP, and the caller is a base-function from the artifacts.

Even so, this is the code of the artifact that triggers the error

Code

How the error looks like

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

solo2k
  • 21
  • 3
  • please share text as text. not screenshots of text. otherwise we cannot copy it – Piglet Mar 29 '21 at 14:03
  • the provided code has less than 61 lines. the error is reported at line 61 of scheduler.lua. there is an upvalue `fn` in your code but your code does not contain a call to `getBoundaryFunc` nor its return value. in order to find out why `fn` is nil you need to check that – Piglet Mar 29 '21 at 14:19
  • I've added the whole code, didn't work for the first time. – solo2k Mar 29 '21 at 14:36

1 Answers1

0

The screenshot of your code shows two calls to getBoundaryFunc

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

In order for fn to become nil either of this funcions must be called without proving the first parameter.

  1. find out wether there are more calls to getBoundaryFunc
  2. find out if its return values are called with nil instead of the expected function value as first parameter
  3. fix that
Piglet
  • 27,501
  • 3
  • 20
  • 43