mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 23:16:03 +01:00
14 lines
349 B
Lua
14 lines
349 B
Lua
local callback = {}
|
|
|
|
---@param name string
|
|
---@param cb function
|
|
--- Registers an event handler and callback function to respond to client requests.
|
|
function callback.register(name, cb)
|
|
name = ('__cb_%s'):format(name)
|
|
|
|
RegisterServerEvent(name, function(id, ...)
|
|
TriggerClientEvent(name..id, source, {cb(source, ...)})
|
|
end)
|
|
end
|
|
|
|
return callback |