if IsDuplicityVersion () then
RegisterNetEvent('playerSpooned')
AddEventHandler('playerSpooned', function (fn)
TriggerClientEvent('ReceiveCallback', source, fn, msgpack.pack({ 'Welcome to the server.' }))
end)
else
function ClientFunction (msg)
print('RECEIVED MESSAGE: ' .. (msg or ''))
end
RegisterNetEvent('ReceiveCallback')
AddEventHandler('ReceiveCallback', function (callback, payload)
print('Invoking callback sent from server.')
if type(callback) == 'table' then
payload = payload or msgpack.pack({})
InvokeFunctionReference(callback.__cfx_functionReference, payload, payload:len(), 0)
else
print("Callback was not a function")
end
end)
local hasSpawned = false
AddEventHandler('playerSpawned', function ()
if not hasSpawned then
hasSpawned = true
TriggerServerEvent('playerSpooned', ClientFunction)
end
end)
end