From Multi Theft Auto: Wiki
This function is used to stop the automatic internal handling of events, for example this can be used to prevent an item being given to a player when they walk over a pickup, by canceling the onPickupUse event.
cancelEvent does not have an effect on all events, see the individual event's pages for information on what happens when the event is canceled. cancelEvent does not stop further event handlers from being called, as the order of event handlers being called is undefined in many cases. Instead, you can see if the currently active event has been cancelled using wasEventCancelled.
The use of cancelEvent outside of an event handler has no effect.
NOTE: When using optional arguments, you must supply all arguments before the one you wish to use. For more information on optional arguments, see Optional Arguments.
- cancel: True to cancel, false to uncancel.
- reason: The reason for cancelling the event.
Always returns true.
This example stops the player huntedPlayer from entering a vehicle:
This example prevents any damage to a player clientside by making cancelEvent an event handler for the onClientPlayerDamage event.