Passing Actions/Functions via exports

I don’t really know if this is possible, but I’m trying to invoke a lua export that involves a callback by passing an Action object.

Here is the code:

C#:

                void Callback(object x)
                {
                    var info = (object[]) x;
                    Debug.WriteLine("Callback invoked!");
                }

                Exports[API.GetCurrentResourceName()].httpRequest("https://google.com/",
                    "GET", null, null, new Action<object>(Callback));

lua:

function httpRequest(url, method, info, headers, callback)
    Citizen.Trace('request received...\n')
    info = info or {}
    headers = headers or {}
    if not callback then
        Citizen.Trace('"callback" is nil\n')
        return
    end

    Citizen.Trace('sending out request\n')
    PerformHttpRequest(url, function(code, content, headers)
        Citizen.Trace('got callback, invoking action')
        local res = {code, content, headers}
        callback(res)
    end, method, json.encode(info, headers))
end

It just keeps tracing ““callback” is nil” so I guess i’m doing something wrong here, or that it is not possible at all. If it’s not possible, is there a workaround?

UPDATE: No matter what I pass as the 5th argument, it seems to be relieved as nil? I don’t know if there is an argument limit in this or what…

(sorry)
ANOTHER UPDATE: When I pass everything as an array to the lua, then it works??? Is there an argument limit or a bug…

hm, might be the arguments in the middle being null is breaking something somewhere

1 Like

Also, another thing (really only related to http), whenever I specify to post the server the server says that it’s receiving a “GET” request… Maybe another bug???