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.