Events::Event: Difference between revisions
(Created page with "__NOTOC__ ===Description=== OOP constructor of Events' add function ===Syntax=== {{Shared}} <syntaxhighlight lang="javascript"> let ev = new mp.Event(name, fu...") |
mNo edit summary |
||
| Line 6: | Line 6: | ||
{{Shared}} | {{Shared}} | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
let ev = new mp.Event(name, | let ev = new mp.Event(name, functionHandler); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
===Required arguments=== | ===Required arguments=== | ||
*'''name''': {{RageType|String}} | *'''name''': {{RageType|String}} | ||
*''' | *'''functionHandler''': '''<span style="color:#008017">(...args: any) => void</span>''' | ||
===Returned value=== | ===Returned value=== | ||
Revision as of 21:43, 19 January 2018
Description
OOP constructor of Events' add function
Syntax
Shared
let ev = new mp.Event(name, functionHandler);
Required arguments
- name: String
- functionHandler: (...args: any) => void
Returned value
- Event Handler
Example
let ev = new mp.Event("playerDeath", (player, reason, killer) =>
{
mp.players.broadcast('First blood!');
ev.destroy(); // this event handler will be not called anymore since it's destroyed
});
ev.destroy(); // due to this line the event is never going to be executed if we call this before it