CallEvent: Difference between revisions

From Onset Developer Wiki
28days (talk | contribs)
No edit summary
No edit summary
Line 1: Line 1:
{{Info|Function|Server & Client|1.0}}
{{Info|Function|Server & Client|1.0}}


{{FuncDescription|The event to call from the same package.}}
{{FuncDescription|The event to call by name. Will call events in all packages.}}


{{FuncSyntax|CallEvent(EventName [, UserArgs...])}}
{{FuncSyntax|CallEvent(EventName [, UserArgs...])}}


{{FuncParameters}}
{{FuncParameters}}
{{FuncParam|EventName |The event name.}}
{{FuncParam|EventName|The event name.}}
{{FuncParamOptional|UserArgs|The passed user arguments to the function.}}
{{FuncParamOptional|UserArgs|The passed user arguments to the function.}}


Line 13: Line 13:
== Example ==
== Example ==
<syntaxhighlight lang="Lua>
<syntaxhighlight lang="Lua>
-- code
function SetPlayerLoggedIn(player)
PlayerData[player].logged_in = true
SetPlayerRandomColor(player)
 
CallEvent("OnPlayerLoggedIn", player)
end
</syntaxhighlight>
</syntaxhighlight>



Revision as of 09:32, 2 September 2020

CallEvent

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

Description

The event to call by name. Will call events in all packages.

Syntax

CallEvent(EventName [, UserArgs...])

Parameters

  • EventName
    The event name.
  • UserArgs (optional)
    The passed user arguments to the function.

Return Value

  • This function has no specific return value.

Example

function SetPlayerLoggedIn(player)
	PlayerData[player].logged_in = true
	SetPlayerRandomColor(player)

	CallEvent("OnPlayerLoggedIn", player)
end

See also