TriggerServerEvent
triggerServerEvent
Sends a reliable ordered resource event from the local client to the server.
Syntax
bool triggerServerEvent(string eventName, element sourceElement, ...)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
eventName |
string |
yes | The server event name, up to 128 bytes. |
sourceElement |
element |
yes | The event source; normally root.
|
... |
nil/bool/number/string |
no | Values sent with the event. |
Returns
Returns true when the event is queued for transmission; otherwise returns false.
Examples
Request an item from the server:
triggerServerEvent("inventory:requestItem", root, "ITMW_1H_SWORD_01")
Notes
- Available only in client-side resource scripts.
- The server must declare the event with
addEvent(eventName, true)and validate the true sender before changing authoritative state. - The authenticated sender's player ID is passed to the server handler before the values supplied by the client.
Security changes since 0.1.4
Use getEventClient for the authenticated initiating client on the server. For direct remote events, sourceResource is nil and eventOrigin is client; do not trust a resource name sent by the client. Existing event arguments are unchanged. Every remote handler must still validate permissions and gameplay state; triggering an event does not grant authority.