Skip to content
M2O Scripting APIScripting reference
Data shapeServer APIGenerated

EventMap

Defined in: server/api.d.ts:2704

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

actionPointHit: [ActionPoint, Player]

Defined in: server/api.d.ts:2873

Dispatched when a player activates a replicated action point.


consoleCommand: [string, string[]]

Defined in: server/api.d.ts:2718

Dispatched after the server console parses a command line that is not handled by a built-in command.


doorInteract: [Player, string, boolean, boolean, number]

Defined in: server/api.d.ts:2853

Dispatched after a player opens, closes, kicks, locks or lockpicks a world door, with the door’s new state. doorId is the id the Door functions take; virtualWorld is the world whose door state changed. Never dispatched for a door whose interaction is disabled.


entityStateChange: [Entity, string, any, any]

Defined in: server/api.d.ts:2958

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.


jukeboxUse: [Player, number]

Defined in: server/api.d.ts:2868

Dispatched when a player uses a synchronized jukebox.


liftArrive: [string, number, number]

Defined in: server/api.d.ts:2863

Dispatched when a lift reaches the floor a player or Lift.setFloor sent it to. Timed on the server with the game’s own lift motion, so it lands within a fraction of a second of the cab stopping on players’ screens.


liftCall: [Player, string, number, number]

Defined in: server/api.d.ts:2858

Dispatched when a player presses a lift button, before the lift sets off for the floor they asked for. Return false from a handler to keep the lift where it is, for a locked floor or a keycard. liftId is the id the Lift functions take; virtualWorld is the world whose lift would move. A press while the lift travels elsewhere is dispatched at once too; if allowed, the lift goes there as soon as its current move ends. Never dispatched for a lift whose buttons are disabled, one already at that floor, or one already on its way there.


markerHit: [Marker, Player]

Defined in: server/api.d.ts:2878

Dispatched when a player enters a marker’s trigger radius.


markerLeave: [Marker, Player]

Defined in: server/api.d.ts:2893

Dispatched when a player leaves a marker’s trigger radius.


npcDeath: [Npc, Player | null, NpcDeathInfo]

Defined in: server/api.d.ts:2783

Dispatched when a server-driven NPC dies, whether from a player’s hit or from npc.kill().


playerAmmoChange: [Player, number, number, number]

Defined in: server/api.d.ts:2763

Dispatched when the reserve or loaded ammunition of a carried weapon changes. Reported at most once per client frame, so a burst of fire arrives as one change.


playerChat: [Player, string]

Defined in: server/api.d.ts:2798

Dispatched when a player submits a chat message.


playerCommand: [Player, string, string[]]

Defined in: server/api.d.ts:2803

Dispatched when a player’s chat input is parsed as a command.


playerConnect: [Player]

Defined in: server/api.d.ts:2723

Dispatched after an M2O player is connected and its script handle can be resolved.


playerConnecting: [PendingConnection]

Defined in: server/api.d.ts:2963

Dispatched when a player asks to join, before the connection exists: they hold no player slot, are not counted as online, and are sent nothing – no resource list, no download, no body. The request waits until every handler has returned and every Promise a handler returned has settled, then it is let in if a player slot is free (otherwise it is refused as full). connection.reject() turns it away instead, and so does a handler that throws or rejects, or handlers that have not settled within the server’s admission timeout (30 seconds by default, restarted by every connection.update()). With no handler at all, every request is let in at once.


playerDamage: [Player, PlayerDamageInfo]

Defined in: server/api.d.ts:2788

Dispatched when the server relays a bullet hit the shooter resolved against a player. Fires before the victim applies it, so the resulting health arrives with that player’s next sync.


playerDeath: [Player, Player | null, PlayerDeathInfo]

Defined in: server/api.d.ts:2778

Dispatched after the server receives and resolves a player’s death report.


playerDialNumber: [Player, number, string, number]

Defined in: server/api.d.ts:2848

Dispatched after a player dials a registered phone-book number.


playerDisconnect: [Player]

Defined in: server/api.d.ts:2728

Dispatched when an M2O player disconnects.


playerPinupCollected: [Player, number, number]

Defined in: server/api.d.ts:2843

Dispatched when a player takes a pinup collectible — the Playboy magazines and the wanted posters, told apart by galleryId, where 1 is the wanted-poster gallery. The collectible is already recorded against the player and hidden on their client; any reward is up to the gamemode. Collected sets are per player and live only for the session, so persist them yourself and restore them with setPinupCollected.


playerShopBuy: [Player, string, number, number, number, boolean, string]

Defined in: server/api.d.ts:2838

Dispatched after a player buys an item from a native shop; price is expressed in currency units.


playerShopClose: [Player, string, number, string]

Defined in: server/api.d.ts:2833

Dispatched when a player closes a native shop.


playerShopEnter: [Player, string, string, boolean, string]

Defined in: server/api.d.ts:2823

Dispatched when a player triggers a city shop, whether or not the native menu came up. nativeOpened is false when a client shopOpen handler suppressed the menu or the game refused the open; source is "walkIn" or "script".


playerShopOpen: [Player, string, string]

Defined in: server/api.d.ts:2828

Dispatched when a player opens a native shop. shopName is the friendly shopmenu2 configuration name, which is what the client’s Shop.open and this side’s Shop.setItem take; shopPath is the internal shop script path.


playerSpawn: [Player]

Defined in: server/api.d.ts:2733

Dispatched after an M2O player spawns or respawns.


playerSubmerged: [Player, Vehicle | null]

Defined in: server/api.d.ts:2793

Dispatched when a player goes underwater and the game’s drowning sequence starts (it resurfaces them on the nearest shore). vehicle is the one they went under in, or null on foot.


playerVoiceStart: [Player]

Defined in: server/api.d.ts:2768

Dispatched when a player starts speaking on voice chat. Tracks speech rather than the push-to-talk key – silence never reaches the server – and fires whether or not anyone is in earshot.


playerVoiceStop: [Player]

Defined in: server/api.d.ts:2773

Dispatched shortly after a player’s last voice frame reaches the server. A disconnect ends talking without this event, since the player is already gone; clean up on playerDisconnect too.


playerWaypointCleared: [Player, number, number]

Defined in: server/api.d.ts:2818

Dispatched when a player clears the active GPS waypoint.


playerWaypointReached: [Player, number, number]

Defined in: server/api.d.ts:2813

Dispatched when a player reaches the active GPS waypoint.


playerWaypointSet: [Player, number, number]

Defined in: server/api.d.ts:2808

Dispatched when a player places a GPS waypoint.


playerWeaponAdd: [Player, number, number, number]

Defined in: server/api.d.ts:2753

Dispatched when a weapon enters a player’s inventory, by any route: giveWeapon, a pickup, a shop, or a client the server never told to add it.


playerWeaponFire: [Player, number, Vector3, Vector3]

Defined in: server/api.d.ts:2743

Dispatched when the server receives a weapon-fire report from a player.


playerWeaponRemove: [Player, number]

Defined in: server/api.d.ts:2758

Dispatched when a weapon leaves a player’s inventory: removeWeapon, a drop, a thrown weapon used up, or a respawn reset.


playerWeaponSwitch: [Player, number, number]

Defined in: server/api.d.ts:2738

Dispatched after the server receives the player’s authoritative weapon-switch update.


playerWeaponThrow: [Player, number, Vector3, number]

Defined in: server/api.d.ts:2748

Dispatched when a player releases a grenade or Molotov.


resourceStart: [string]

Defined in: server/api.d.ts:2708

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


resourceStop: [string]

Defined in: server/api.d.ts:2713

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


vehicleDestroy: [Vehicle]

Defined in: server/api.d.ts:2903

Dispatched immediately before or while a replicated vehicle is destroyed.


vehicleExplode: [Vehicle, Player | null]

Defined in: server/api.d.ts:2908

Dispatched when a replicated vehicle explodes.


vehicleLightBroken: [Vehicle, number]

Defined in: server/api.d.ts:2918

Dispatched when one of a vehicle’s headlights is smashed by body deformation.


vehiclePartDropped: [Vehicle, number, number]

Defined in: server/api.d.ts:2913

Dispatched when a vehicle deform part is torn off its body. partType is a VehiclePartType value.


vehiclePlayerEntered: [Vehicle, Player]

Defined in: server/api.d.ts:2943

Dispatched after a player has entered a vehicle.


vehiclePlayerEntering: [Vehicle, Player, number]

Defined in: server/api.d.ts:2938

Dispatched when a player begins entering a vehicle seat.


vehiclePlayerExited: [Vehicle, Player]

Defined in: server/api.d.ts:2953

Dispatched after a player has exited a vehicle.


vehiclePlayerExiting: [Vehicle, Player]

Defined in: server/api.d.ts:2948

Dispatched when a player begins exiting a vehicle.


vehicleRadioChange: [Vehicle, Player, number]

Defined in: server/api.d.ts:2933

Dispatched after a vehicle driver changes its radio station.


vehicleSpawn: [Vehicle]

Defined in: server/api.d.ts:2898

Dispatched immediately after a replicated vehicle is created.


vehicleSubmerged: [Vehicle]

Defined in: server/api.d.ts:2923

Dispatched when a replicated vehicle goes underwater.


vehicleSurfaced: [Vehicle]

Defined in: server/api.d.ts:2928

Dispatched when a previously submerged replicated vehicle leaves the water.


volumeHit: [Volume, Player]

Defined in: server/api.d.ts:2883

Dispatched when a player enters a volume. The crossing is detected by the game’s own physics sensor on that player’s client, not by polling, so it fires on body overlap rather than when the player’s origin crosses the boundary.


volumeLeave: [Volume, Player]

Defined in: server/api.d.ts:2888

Dispatched when a player leaves a volume, including when the volume is disabled, moved away or destroyed. A player who disconnects leaves without this event, so clean up on playerDisconnect too.