Skip to content
M2O Scripting APIScripting reference
Data shapeClient APIGenerated

EventMap

Defined in: client/api.d.ts:1769

Native events dispatched through Events.on. Each property is the exact callback argument tuple for that event.

browserConsoleMessage: [BrowserConsoleMessageEvent]

Defined in: client/api.d.ts:1908

Dispatched for console output of an owned view; the framework logs these regardless.


browserCreated: [BrowserCreatedEvent]

Defined in: client/api.d.ts:1858

Dispatched once per view, before any navigation, to the resource that created it.


browserCursorChange: [BrowserCursorChangeEvent]

Defined in: client/api.d.ts:1888

Dispatched when an owned view’s requested cursor shape changes.


browserDocumentReady: [BrowserDocumentReadyEvent]

Defined in: client/api.d.ts:1868

Dispatched when an owned view’s main document is ready; the earliest point at which the page can receive Web.emit.


browserInputFocusChange: [BrowserInputFocusChangeEvent]

Defined in: client/api.d.ts:1898

Dispatched when focus enters or leaves an editable element of an owned view; use it to stop routing keys to the game.


browserLoadingFailed: [BrowserLoadingFailedEvent]

Defined in: client/api.d.ts:1873

Dispatched when a frame of an owned view fails to load.


browserLoadingStart: [BrowserLoadingStartEvent]

Defined in: client/api.d.ts:1863

Dispatched when any frame of an owned view begins loading.


browserNavigate: [BrowserNavigateEvent]

Defined in: client/api.d.ts:1878

Dispatched for every navigation an owned view is asked to perform, refused or not.


browserOriginChange: [BrowserOriginChangeEvent]

Defined in: client/api.d.ts:1913

Dispatched on view creation and whenever Web.loadURL re-locks an owned view to a different origin.


browserPopup: [BrowserPopupEvent]

Defined in: client/api.d.ts:1883

Dispatched when an owned view blocks a popup; windowless views cannot host one, so handle the URL yourself.


browserResourceBlocked: [BrowserResourceBlockedEvent]

Defined in: client/api.d.ts:1903

Dispatched when an owned view rejects a navigation or a page event from outside its locked origin.


browserTooltip: [BrowserTooltipEvent]

Defined in: client/api.d.ts:1893

Dispatched when an owned view requests a tooltip; windowless rendering draws none, so the script must.


chatMessage: [ChatMessageEvent]

Defined in: client/api.d.ts:1783

Dispatched when the client receives a framework chat-message RPC, before the built-in chat overlay is updated.


chatSend: [string]

Defined in: client/api.d.ts:1788

Dispatched synchronously when the local player submits a chat line, before it is sent. Return false to keep the line client-side; async handlers cannot block it. Not dispatched for Chat.send.


cityPartChanged: [CityPartChangeEvent]

Defined in: client/api.d.ts:1813

Dispatched when the local player crosses into a different city district.


dialogAnswer: [QuestionAnswerEvent]

Defined in: client/api.d.ts:1803

Dispatched when a prompt shown by Ui.showDialog resolves. answerId is 1 for the accepting option and 2 for the declining one.


entityStateChange: [Entity, string, any, any]

Defined in: client/api.d.ts:1853

Dispatched when one key of an entity’s state changes: on the server when a script writes it, on a client when the write arrives. value is undefined when the key was removed and previous is undefined when it held nothing before, so a stored null stays distinguishable from an absent key. The entity is whatever the game’s WrapScriptEntity answers, and the base Entity handle by default.


lockpickResult: [LockpickResultEvent]

Defined in: client/api.d.ts:1808

Dispatched when a minigame started by Ui.startLockpick ends, including when Ui.cancelLockpick closes it.


playerDamage: [PlayerDamageEvent]

Defined in: client/api.d.ts:1828

Dispatched immediately after the local player receives native damage.


questionAnswer: [QuestionAnswerEvent]

Defined in: client/api.d.ts:1798

Dispatched when a prompt shown by Ui.showQuestion resolves. Not dispatched for Ui.showDialog, which raises dialogAnswer, nor for a prompt closed by Ui.cancelQuestion.


radioPowerChange: [RadioPowerChangeEvent]

Defined in: client/api.d.ts:1823

Dispatched after the local player’s vehicle radio is turned on or off.


radioStationChange: [RadioStationChangeEvent]

Defined in: client/api.d.ts:1818

Dispatched after the local player’s vehicle radio changes station.


resourceStart: [string]

Defined in: client/api.d.ts:1773

Dispatched after a resource entry point has run and immediately before the resource becomes running.


resourceStop: [string]

Defined in: client/api.d.ts:1778

Dispatched while a resource is stopping, before its stop callback, timers, exports, and event handlers are cleaned up.


shopOpen: [ShopOpenEvent]

Defined in: client/api.d.ts:1793

Dispatched synchronously before Mafia II’s native shop menu opens. Return false to suppress it entirely: no menu is drawn and no shop camera transition starts, which is what replacing the shop with a custom interface needs. Async handlers cannot block it. The server still receives playerShopEnter.


voiceStart: []

Defined in: client/api.d.ts:1843

Dispatched when the local player starts speaking on voice chat. Tracks speech rather than the push-to-talk key: a held key with nothing said never starts. Client-side voice is local only – for other players, listen for playerVoiceStart on the server.


voiceStop: []

Defined in: client/api.d.ts:1848

Dispatched when the local player stops speaking, either on releasing push-to-talk or shortly after the last frame the microphone produced.


volumeHit: [VolumeContactEvent]

Defined in: client/api.d.ts:1833

Dispatched when the local player enters a volume, raised straight from the game’s own physics sensor with no server round-trip – react locally here and let the server’s own volumeHit handle anything authoritative. Fires on body overlap, not when the player’s origin crosses the boundary.


volumeLeave: [VolumeContactEvent]

Defined in: client/api.d.ts:1838

Dispatched when the local player leaves a volume, including when the volume is disabled, moved away or destroyed.