TriggerEvent: Difference between revisions

From Wiki G1R-MP G1 Remake Multiplayer
Jump to navigation Jump to search
Automatyczna aktualizacja dokumentacji funkcji
 
Complete Lua function catalog
 
Line 37: Line 37:
* Event arguments are limited to nil, boolean, number and string values.
* Event arguments are limited to nil, boolean, number and string values.


[[Category:Lua Functions]]
[[Category:Shared Functions]]
[[Category:Shared Functions]]
[[Category:Event Functions]]
[[Category:Event Functions]]

Latest revision as of 09:55, 15 August 2026

triggerEvent

Triggers a custom event inside the current runtime.

Syntax

bool triggerEvent(string eventName, element sourceElement, ...)

Parameters

Name Type Required Description
eventName string yes The custom event name.
sourceElement element yes The source exposed to event handlers.
... nil/bool/number/string yes Optional event arguments.

Returns

Returns true when the event is dispatched successfully; otherwise returns false.

Examples

Trigger a local resource event:

addEvent("round:started")
addEventHandler("round:started", root, function(roundNumber)
    print("Round", roundNumber, "started")
end)

triggerEvent("round:started", root, 3)

Notes

  • Available in both client-side and server-side resource scripts.
  • Event arguments are limited to nil, boolean, number and string values.