Events::Event: Difference between revisions
mNo edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
{{SharedFunctionJS}} | |||
===Description=== | ===Description=== | ||
OOP constructor of [[Events::add|Events' add]] function | OOP constructor of [[Events::add|Events' add]] function | ||
===Syntax=== | ===Syntax=== | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
let ev = new mp.Event(name, functionHandler); | let ev = new mp.Event(name, functionHandler); | ||
Revision as of 14:09, 27 November 2018
Description
OOP constructor of Events' add function
Syntax
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