cancellableEvent.preventDefault: Difference between revisions

From GTA Connected
Jump to navigation Jump to search
No edit summary
No edit summary
 
Line 1: Line 1:
{{ScriptItem
{{ScriptItem2
|endpoint = shared
|name = preventDefault
|side = shared
|type = method
|type = method
|class = CancellableEvent
|class = CancellableEvent
|name = preventDefault
|games = iii vc sa iv
|parameters = void
|desc = prevent the default action for the current event which is triggering
|return1 = void
|return = void
|returnFail1 = void
|freturn = void
|usage = prevent the default action for the current event which is triggering
|note = See also: [[event.isDefaultPrevented|event.isDefaultPrevented]]
|notes = See also: [[event.isDefaultPrevented|event.isDefaultPrevented]]
|exampleJSCS = addEventHandler('onPedInflictDamage', function(event, ped, responsibleEntity, weapon, loss, pedPiece)
|exampleJSCS = addEventHandler('onPedInflictDamage', function(event, ped, responsibleEntity, weapon, loss, pedPiece)
{
{

Latest revision as of 20:36, 19 November 2022

Method Server and Client icon-iii.png icon-vc.png icon-sa.png icon-iv.png Online and Offline

Available since Server 1.0.0, Client 1.0.0

void cancellableEvent.preventDefault(void)

The cancellableEvent.preventDefault method is used to prevent the default action for the current event which is triggering.

Parameters

void This method doesn't take any parameters.

Return

void This method doesn't return a value.

Types

Shared CancellableEvent

Notes

Examples

Example 1 - JavaScript - Client-Side:

addEventHandler('onPedInflictDamage', function(event, ped, responsibleEntity, weapon, loss, pedPiece)
{
    // Prevent the ped from being damaged.
    event.preventDefault();
});

Compatibility

There isn't any compatibility information for this method.

Related

Server Related

icon-iii.png icon-vc.png icon-sa.png icon-iv.png addEvent
icon-iii.png icon-vc.png icon-sa.png icon-iv.png addEventHandler
icon-iii.png icon-vc.png icon-sa.png icon-iv.png bindEventHandler
icon-iii.png icon-vc.png icon-sa.png icon-iv.png removeEventHandler
icon-iii.png icon-vc.png icon-sa.png icon-iv.png triggerEvent
icon-iii.png icon-vc.png icon-sa.png icon-iv.png triggerNetworkEvent
icon-iii.png icon-vc.png icon-sa.png icon-iv.png unbindEventHandler


Client Related

icon-iii.png icon-vc.png icon-sa.png icon-iv.png addEvent
icon-iii.png icon-vc.png icon-sa.png icon-iv.png addEventHandler
icon-iii.png icon-vc.png icon-sa.png icon-iv.png bindEventHandler
icon-iii.png icon-vc.png icon-sa.png icon-iv.png removeEventHandler
icon-iii.png icon-vc.png icon-sa.png icon-iv.png triggerEvent
icon-iii.png icon-vc.png icon-sa.png icon-iv.png triggerNetworkEvent
icon-iii.png icon-vc.png icon-sa.png icon-iv.png unbindEventHandler