mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 15:06:02 +01:00
feat(callback): client callback
Allow the client to listen for and respond to server requests. Basically just copy-paste and swap the two.
This commit is contained in:
@@ -69,4 +69,15 @@ function callback.await(event, delay, ...)
|
||||
return triggerServerCallback(_, event, delay, false, ...)
|
||||
end
|
||||
|
||||
---@param name string
|
||||
---@param cb function
|
||||
--- Registers an event handler and callback function to respond to server requests.
|
||||
function callback.register(name, cb)
|
||||
name = ('__cb_%s'):format(name)
|
||||
|
||||
RegisterNetEvent(name, function(key, ...)
|
||||
TriggerServerEvent(cbEvent, key, { cb(...) })
|
||||
end)
|
||||
end
|
||||
|
||||
return callback
|
||||
|
||||
Reference in New Issue
Block a user