I’m trying to make some code that would allow to call functions from server to client and vice versa more easily. But in order for it to work, there have to be tables passed through events. I get errors when trying to send an event from server to the client. Can events even handle tables?
Code looks like this:
CallClientFunction('somefunctionname', argument1, argument2, argument3)
function CallClientFunction(fname, ...)
print('fname='..fname)
for i,v in ipairs{...} do
print('argument['..i..']='..v)
end
TriggerClientEvent('callClientFunction', 0, fname, ...)
end
RegisterNetEvent('callClientFunction')
AddEventHandler('callClientFunction', function(fname, ...)
local table2={...}
print('fname2='..fname)
for i,v in ipairs(table2) do
print('argumentas2['..i..']='..v)
end
end)
Error:
InvokeNative: execution failed: Argument at index 1 was null.
Error running call reference function for resource grpltu: Execution of native 000000002f7a49e6 in script host failed.
stack traceback:
[C]: in upvalue ‘_in’
citizen:/scripting/lua/natives_server.lua:238: in function ‘TriggerClientEventInternal’
(…tail calls…)