boba-callbacks
Introduction
This resource is to be used as a utility dependency. Routing server events via this utility means you don't need to expose them to clients for sensitive functions (e.g. adding/ removing items).
Contributions can be made by opening a pull request, or if you notice a bug please raise an issue on GitHub.
Any code supplied is provided as-is, without warranty or guaranteed support. You are expected to have any required technical knowledge prior to the use of this resource.
Usage Examples
In this example, we'll use Lua to trigger a server event securely from the client. We avoid the use of RegisterNetEvent, meaning the event is only exposed to server-side scripts - avoiding the possibility for malicious clients to trigger client events without requests first reaching the callbacks handler.
Client
CreateThread(function()
local result = exports["boba-callbacks"]:ExecuteServerCallback("ResourceName:EventName", "Example value sent to the server event")
print(result)
end)Server
AddEventHandler("ResourceName:EventName", function(cb, src, arg)
print(("Event triggered on the server. Value received: %s"):format(arg))
cb("This value is sent to the client")
end)While this utility doesn't expose events to clients directly, you should ensure any data received is properly sanitized before using it in your application.
Last updated
Was this helpful?