AddEvent: Difference between revisions

From Onset Developer Wiki
No edit summary
28days (talk | contribs)
No edit summary
Line 6: Line 6:


{{FuncParameters}}
{{FuncParameters}}
{{FuncParam|EventName|The name of the event. See [[Template:ServerEvents|ServerEvents]] or [[Template:ClientEvents|ClientEvents]] for a list of events.}}
{{FuncParam|EventName|The name of the event. See [[Template:ServerEvents|Server Events]] or [[Template:ClientEvents|Client Events]] for a list of events.}}
{{FuncParam|LuaFunction |The function which will be called when the event occurs.}}
{{FuncParam|LuaFunction |The function which will be called when the event occurs.}}


Line 12: Line 12:


== Example ==
== Example ==
__EDIT_ME__
<syntaxhighlight lang="Lua">
AddEvent("Event Name", function()
    -- code here
end)
</syntaxhighlight>


{{RelatedFunctions}}
{{RelatedFunctions}}
__EDIT_ME__
{{Template:EventFunctions}}

Revision as of 07:05, 13 December 2019

AddEvent

Type: Function
Context: Server & Client
Introduced: v1.0

Description

Adds a function as event handler which will be called when a certain event occurs. Multiple functions can be bound to a single event.

Syntax

AddEvent(EventName, LuaFunction)

Parameters

  • EventName
    The name of the event. See Server Events or Client Events for a list of events.
  • LuaFunction
    The function which will be called when the event occurs.

Return Value

  • This function has no specific return value.

Example

AddEvent("Event Name", function()
    -- code here
end)

See also

Template:EventFunctions