Skip to content
M2O Scripting APIScripting reference
Data shapeServer APIGenerated

EventMap

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

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:2661

Dispatched when a player activates a replicated action point.


consoleCommand: [string, string[]]

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

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


doorInteract: [Player, string, boolean, boolean]

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

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. Never dispatched for a door whose interaction is disabled.


entityStateChange: [Entity, string, any, any]

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

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:2656

Dispatched when a player uses a synchronized jukebox.


markerHit: [Marker, Player]

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

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


markerLeave: [Marker, Player]

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

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


npcDeath: [Npc, Player | null, NpcDeathInfo]

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

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:2561

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:2596

Dispatched when a player submits a chat message.


playerCommand: [Player, string, string[]]

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

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


playerConnect: [Player]

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

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


playerConnecting: [PendingConnection]

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

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:2586

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:2576

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


playerDialNumber: [Player, number, string, number]

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

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


playerDisconnect: [Player]

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

Dispatched when an M2O player disconnects.


playerPinupCollected: [Player, number, number]

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

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:2636

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:2631

Dispatched when a player closes a native shop.


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

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

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:2626

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:2531

Dispatched after an M2O player spawns or respawns.


playerSubmerged: [Player, Vehicle | null]

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

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:2566

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:2571

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:2616

Dispatched when a player clears the active GPS waypoint.


playerWaypointReached: [Player, number, number]

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

Dispatched when a player reaches the active GPS waypoint.


playerWaypointSet: [Player, number, number]

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

Dispatched when a player places a GPS waypoint.


playerWeaponAdd: [Player, number, number, number]

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

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:2541

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


playerWeaponRemove: [Player, number]

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

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:2536

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


playerWeaponThrow: [Player, number, Vector3, number]

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

Dispatched when a player releases a grenade or Molotov.


resourceStart: [string]

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

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


resourceStop: [string]

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

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:2691

Dispatched immediately before or while a replicated vehicle is destroyed.


vehicleExplode: [Vehicle, Player | null]

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

Dispatched when a replicated vehicle explodes.


vehicleLightBroken: [Vehicle, number]

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

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


vehiclePartDropped: [Vehicle, number, number]

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

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:2731

Dispatched after a player has entered a vehicle.


vehiclePlayerEntering: [Vehicle, Player, number]

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

Dispatched when a player begins entering a vehicle seat.


vehiclePlayerExited: [Vehicle, Player]

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

Dispatched after a player has exited a vehicle.


vehiclePlayerExiting: [Vehicle, Player]

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

Dispatched when a player begins exiting a vehicle.


vehicleRadioChange: [Vehicle, Player, number]

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

Dispatched after a vehicle driver changes its radio station.


vehicleSpawn: [Vehicle]

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

Dispatched immediately after a replicated vehicle is created.


vehicleSubmerged: [Vehicle]

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

Dispatched when a replicated vehicle goes underwater.


vehicleSurfaced: [Vehicle]

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

Dispatched when a previously submerged replicated vehicle leaves the water.


volumeHit: [Volume, Player]

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

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:2676

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.