RSG Callback Function

RSGCore.Functions.TriggerCallback

Function used to call from the client to the server and receive a value back

function RSGCore.Functions.TriggerCallback(name, cb, ...)
    RSGCore.ServerCallbacks[name] = cb
    TriggerServerEvent('RSGCore:Server:TriggerCallback', name, ...)
end

-- Example

RSGCore.Functions.TriggerCallback('callbackName', function(result)
    print('I got this from the CreateCallBack -->  '..result)
end, 'my_parameter_name')

RSGCore.Functions.CreateCallback

Creates a callback which is used on the client-side code with RSGCore.Functions.TriggerCallback

function RSGCore.Functions.CreateCallback(name, cb)
    RSGCore.ServerCallbacks[name] = cb
end

-- Example

RSGCore.Functions.CreateCallback('callbackName', function(source, cb)
    cb('Ok')
end)

Last updated