TriggerServerEvent: Difference between revisions

From Wiki G1R-MP G1 Remake Multiplayer
Jump to navigation Jump to search
Automatyczna aktualizacja dokumentacji funkcji
 
Automatyczna aktualizacja dokumentacji funkcji
 
Line 31: Line 31:
* Available only in client-side resource scripts.
* Available only in client-side resource scripts.
* The server must declare the event with <code>addEvent(eventName, true)</code> and validate the true sender before changing authoritative state.
* The server must declare the event with <code>addEvent(eventName, true)</code> 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.


[[Category:Client Functions]]
[[Category:Client Functions]]
[[Category:Network Functions]]
[[Category:Network Functions]]
[[Category:Event Functions]]
[[Category:Event Functions]]

Latest revision as of 12:53, 4 August 2026

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.