Skip to main content

Events::remove

Not available on SYNC MP yet

This member is part of the RAGE:MP API but SYNC MP does not implement it yet (Server-side JavaScript). Calling it does nothing or throws.

Server-side function

Removes the specified event from events tree.

Syntax​

mp.events.remove("eventName"); // Removes all eventName instances
mp.events.remove("eventName", functionInstance); // Removes specified event instance.
mp.events.remove(["eventName1", "eventName2"]); // Removes all specified events instances.

//alternatively you can use '.destroy' if event was created as a class (example below)
event.destroy()

Example​

Shared

function onPlayerDeath(player, reason, killer){
console.log(player.name + " died.");
mp.events.remove("playerDeath", onPlayerDeath); // Once someone died, remove the event.
}
mp.events.add("playerDeath", onPlayerDeath);

//Using class
const myEvent = new mp.Event("playerDeath", (player, reason, killer) => {
console.log(`${player.name} ${killer ? `was killed by ${killer.name}` : `died`}`);
});

myEvent.destroy(); //destroy the event