Callback events
We decided to make these callback as standalone as possible.
So to create one you do:
--- @param onSuccess function A response back to the invoking resource letting it know it was successfull. You might also need to pass a value depending on invoking resource and context.
--- @param onError function If an error occures you can pass this error to this callback so the invoking resource doesn't get stuck waiting on an answer.
--- @param src number | string The server id (source) of the player involed in this request. Only available on server callbacks.
--- @param ... any The rest of the arguments depending on the invoking resource and context.
AddEventHandler("eventName", function(onSuccess, onError, src, ...)
-- Your code here, don't forget to call onSuccess() when done.
end)
/**
* @param {function} onSuccess A response back to the invoking resource letting it know it was successfull. You might also need to pass a value depending on invoking resource and context.
* @param {function} onError If an error occures you can pass this error to this callback so the invoking resource doesn't get stuck waiting on an answer.
* @param {number | string} src The server id (source) of the player involed in this request. Only available on server callbacks.
* @param {any[]} args The rest of the arguments depending on the invoking resource and context.
*/
on("eventName", (onSuccess, onError, src, ...args) => {
// Your code here, don't forget to call onSuccess() when you're done.
})
/**
* @param {function} onSuccess A response back to the invoking resource letting it know it was successfull. You might also need to pass a value depending on invoking resource and context.
* @param {function} onError If an error occures you can pass this error to this callback so the invoking resource doesn't get stuck waiting on an answer.
* @param {number | string} src The server id (source) of the player involed in this request. Only available on server callbacks.
* @param {any[]} args The rest of the arguments depending on the invoking resource and context.
*/
on("eventName", (onSuccess: function, onError: function, src: number | string, ...args: any[]) => {
// Your code here, don't forget to call onSuccess() when you're done.
})