Skip to main content
Aquiver API

Event manager

Register and trigger module-scoped events without event-name conflicts between resources.

Setup overview

Integration notes

Local events

Trigger events locally through the module.

Reusable names

Use the same event names in different resources without checking whether a name already exists.

Table registration

Register multiple events together in a table.

Scoped event names

The module prefixes registered event names to prevent them from conflicting with events in other resources.

API​

Configuration

Event manager functions

Register local or network events and trigger them in the required environment.

---@param eventName string | { [string]: fun(...) }
---@param cb? fun(...)
Shared.EventManager:RegisterModuleNetworkEvent(eventName, cb)
---@param eventName string | { [string]: fun(...) }
---@param cb? fun(...)
Shared.EventManager:RegisterModuleEvent(eventName, cb)

Shared.EventManager:TriggerModuleEvent(eventName, ...)
Shared.EventManager:TriggerModuleServerEvent(eventName, ...)
Shared.EventManager:TriggerModuleClientEvent(eventName, ...)

Registering and triggering a single event​

Configuration

Register an event

Register a single local module event.

Example
Shared.EventManager:RegisterModuleEvent("JobStarted", function(jobName)
print(jobName) -- "miner"
end)

For example, if the resource is named job_miner and the registered module event is JobStarted, the resulting event name is job_miner:JobStarted.

Configuration

Trigger the event

Trigger the registered local event with its arguments.

Triggering the local event
Shared.EventManager:TriggerModuleEvent("JobStarted", "miner")

Registering events in a table​

Configuration

Register multiple events

Register multiple local module events from one table.

Shared.EventManager:RegisterModuleEvent({
["JobStarted"] = function(jobName)
print(jobName)
end,
["JobEnded"] = function(jobName)
print(jobName)
end
})