Events::Event

From RAGE Multiplayer Wiki
Revision as of 20:15, 19 January 2018 by Mcfloy (talk | contribs) (Created page with "__NOTOC__ ===Description=== OOP constructor of Events' add function ===Syntax=== {{Shared}} <syntaxhighlight lang="javascript"> let ev = new mp.Event(name, fu...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Description

OOP constructor of Events' add function

Syntax

Shared
let ev = new mp.Event(name, function);

Required arguments

  • name: String
  • function: (...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