addEvent
Shared
Registers a new event under this name. Only then can handlers be added to it and can it be triggered.
bool addEvent(string name [, bool allowRemoteTrigger = false])
Parameters
| Name | Type | Description |
|---|---|---|
| name | string | The event's name. |
| allowRemoteTrigger | bool | Let the other side trigger the event with triggerServerEvent, triggerClientEvent or their latent versions.default false |
Returns
true if it was registered, false if the name is empty or an event with that name already exists.
The event stops existing when the resource that registered it stops.
Example
addEvent("onPlayerBuyItem", true)
addEventHandler("onPlayerBuyItem", root, function(itemId)
outputDebugString(getPlayerName(client) .. " bought item " .. tostring(itemId))
end)NoteAn event that arrives from the other side without
allowRemoteTrigger is dropped, with only a line in the log.