ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Server functions
  3. addRemoteHandler

Function

addRemoteHandler

ServerEventsTrilogy Hub only

Registers an event sent by the client with protection: a per-player call limit, a source check and an argument count check. Rejected calls go to the server log.

Syntax

function addRemoteHandler(string name, element element, function handler [, table options = nil])

Arguments

namestring
The event name.
elementelement
The element the handler is attached to (usually root).
handlerfunction
The handler; client is the sending player.
optionstable, optional = nil
limit = { count, windowMs }, sourceIsClient, maxArgs, propagate.

Returns

The function to pass to removeEventHandler.

Example

addRemoteHandler("onShopBuy", root, function(item)
    outputChatBox("Kupiono: " .. tostring(item), client)
end, { limit = { 5, 10000 }, sourceIsClient = true, maxArgs = 1 })

See also