TriggerEvent with table in argument doesn't work properly


#1

Hi,

When using TriggerEvent and putting a table as an argument, this creates a “clone” of the table when retrieving it in AddEventHandler.

This is not logical, especially when working with global tables. (class)

Try by yourself:

RegisterNetEvent("MyEvent")

MyTable = {}

Citizen.Trace("MyTable just initialized: " .. tostring(MyTable))


Citizen.CreateThread(function()
    while true do
        Citizen.Wait(0)
        
        if NetworkIsSessionStarted() then
            TriggerEvent("MyEvent", MyTable)
            break
        end
    end
end)


AddEventHandler("MyEvent", function(table) 
    Citizen.Trace("MyTable in event handler: " .. tostring(table))
end)


Table “ID” should be the same.