M2O Scripting APIScripting reference
    Preparing search index…
    ClassServer API

    Player

    A connected M2O player.

    Hierarchy

    • Player
      • Player
    Index
    • Creates a script wrapper for an existing connected player with this ID; it does not create a player.

      Parameters

      • id: number

        Network entity identifier.

      Returns Player

    • Adds cash to this player's native inventory and HUD counter.

      Parameters

      • amount: number

        Cash amount in dollars to add.

      Returns void

    • Clears this player's left-hand, right-hand, and mouth prop models.

      Returns void

    • Removes a persistent HUD hint from this player.

      Parameters

      • tag: number

        Tag assigned when the persistent hint was shown.

      Returns void

    • Parameters

      • eventName: string
      • OptionalpayloadJson: string

      Returns void

    • Returns the most recently replicated animation-set identifier.

      Returns number

      The applied animation-set ID, or zero when no override is active.

    • Returns the most recently replicated held-weapon identifier.

      Returns number

      The current weapons.tbl row ID; 1 represents fists.

    • Returns the most recently owner-reported health value.

      Returns number

      Current replicated health, including native damage.

    • Returns the most recently owner-reported cash balance.

      Returns number

      Current balance in dollars, including native in-game spending.

    • Returns the player's current replicated on-foot gait.

      Returns "idle" | "walking" | "running" | "stopping"

      One of idle, walking, running, or stopping.

    • Returns the vehicle currently occupied by this player in any seat.

      Returns Vehicle | null

      The current vehicle handle, or null when the player is not in a vehicle.

    • Changes reserve ammunition for one of this player's weapons.

      Parameters

      • weaponId: number

        weapons.tbl row identifier.

      • amount: number

        Reserve ammunition delta; negative values remove ammunition.

      Returns void

    • Adds a valid weapon to this player's native inventory.

      Parameters

      • weaponId: number

        weapons.tbl row identifier.

      • ammo: number

        Initial reserve ammunition amount.

      • equip: boolean

        Whether the weapon should become the current weapon immediately.

      Returns void

    • Smoothly moves this player's camera from its current view to a fixed destination until resetCamera is called.

      Parameters

      • x: number

        Destination camera world-space X coordinate.

      • y: number

        Destination camera world-space Y coordinate.

      • z: number

        Destination camera world-space Z coordinate.

      • lookX: number

        Destination world-space look-at X coordinate.

      • lookY: number

        Destination world-space look-at Y coordinate.

      • lookZ: number

        Destination world-space look-at Z coordinate.

      • durationSeconds: number

        Transition duration in seconds.

      Returns void

    • Checks the player's most recently replicated crouch state.

      Returns boolean

      True when the player is crouching.

    • Checks the player's most recently reported death state.

      Returns boolean

      True when the player is dead.

    • Parameters

      • Optionalreason: string

      Returns void

    • Shows or clears visual prop models in this player's hands. Hand slots are shared with the equipped weapon.

      Parameters

      • enabled: boolean

        False clears both hand slots; true applies the supplied models.

      • leftModelId: number

        weapons.tbl prop-row ID for the left hand; an unknown ID clears the slot.

      • rightModelId: number

        weapons.tbl prop-row ID for the right hand; an unknown ID clears the slot.

      Returns void

    • Shows a visual prop model in this player's mouth.

      Parameters

      • modelId: number

        weapons.tbl prop-row ID; an unknown ID clears the mouth slot.

      Returns void

    • Requests the native shop interface for this player; opening is a no-op when the shop is not streamed.

      Parameters

      • shopName: string

        shopmenu2.bin configuration name of a shop streamed on the player's client.

      Returns void

    • Plays a non-spatial police dispatch line server-wide.

      Parameters

      • event: string

        Police radio event name from the shared event registry.

      Returns boolean

      False when the event name is unknown.

    • Removes cash from this player's native inventory.

      Parameters

      • amount: number

        Cash amount in dollars to remove; removal is clamped to the available balance.

      Returns void

    • Removes one weapon from this player's inventory and switches to fists when necessary.

      Parameters

      • weaponId: number

        weapons.tbl row identifier to remove.

      Returns void

    • Overrides this player's walk and idle animation style.

      Parameters

      • category: "common" | "weapon" | "panic" | "melee"

        Animation-style registry category.

      • style: string

        Registered style name within the selected category.

      Returns boolean

      True when the category and style were found and applied.

    • Cuts this player's camera to a fixed position and look-at target until resetCamera is called.

      Parameters

      • x: number

        Camera world-space X coordinate.

      • y: number

        Camera world-space Y coordinate.

      • z: number

        Camera world-space Z coordinate.

      • lookX: number

        World-space X coordinate the camera looks at.

      • lookY: number

        World-space Y coordinate the camera looks at.

      • lookZ: number

        World-space Z coordinate the camera looks at.

      Returns void

    • Sets whether this player's owning client accepts gameplay controls.

      Parameters

      • enabled: boolean

        True to accept gameplay input; false to lock movement, combat, and vehicle controls.

      Returns void

    • Equips one of this player's owned weapons.

      Parameters

      • weaponId: number

        Owned weapons.tbl row identifier to equip.

      Returns void

    • Applies the native temporary drunkenness effect, including camera shake and aim sway.

      Parameters

      • value: number

        Drunkenness from 0 for sober to 1 for fully drunk.

      Returns void

    • Sets this player's health on the owning client.

      Parameters

      • health: number

        Target health value, clamped to the pedestrian's native maximum.

      Returns void

    • Changes this player's body model and replicates the new skin.

      Parameters

      • modelIndex: number

        Index in the shared player-model registry.

      Returns void

    • Recolors this player's current outfit without reloading the model; unsupported variants are ignored.

      Parameters

      • colorId: number

        Per-model palette variant; -1 restores the default.

      Returns void

    • Selects and applies a random model from the Mafia II player model directory.

      Returns void

    • Sets the recognition/search meter beside the player's minimap.

      Parameters

      • value: number

        Recognition level from 0 for empty to 1 for full.

      Returns void

    • Enables or disables unlimited ammunition for this player.

      Parameters

      • enabled: boolean

        Whether this player's ammunition is infinite.

      Returns void

    • Parameters

      • world: number

      Returns void

    • Parameters

      • player: Entity | null

      Returns void

    • Sets the player's native wanted-level HUD icon.

      Parameters

      • level: number

        Wanted escalation level from 0 through 4.

      Returns void

    • Sets visibility of the player's wanted-person HUD tag.

      Parameters

      • shown: boolean

        Whether the native wanted-person icon is shown.

      Returns void

    • Sets or replaces this player's GPS waypoint and computes a client-side route.

      Parameters

      • x: number

        World-space X coordinate of the destination.

      • y: number

        World-space Y coordinate of the destination.

      • Optionalz: number

        Optional world-space Z coordinate; routing uses the map's two-dimensional road graph.

      Returns void

    • Sets absolute ammunition counts for one of this player's weapons.

      Parameters

      • weaponId: number

        weapons.tbl row identifier.

      • total: number

        Absolute reserve ammunition amount.

      • clip: number

        Absolute loaded-clip amount; a negative value preserves the current clip.

      Returns void

    • Shows a native two-choice confirmation dialog. The result is emitted as playerDialogAnswer.

      Parameters

      • questionId: number

        Opaque caller-defined ID echoed by the playerDialogAnswer event.

      • title: string

        Dialog question or title text.

      • acceptLabel: string

        Label for the accepting option.

      • declineLabel: string

        Label for the declining option.

      • timeoutSeconds: number

        Time before the dialog is dismissed automatically.

      Returns void

    • Shows a configurable native hint on this player's HUD.

      Parameters

      • text: string

        Hint text displayed to the player.

      • area: number

        Native script-hint area identifier from 0 through 3.

      • color: number

        ARGB color value; -1 uses white.

      • durationSeconds: number

        Display duration in seconds when the hint is not persistent.

      • persist: boolean

        Whether the hint remains until explicitly destroyed.

      • tag: number

        Caller-defined identifier used by destroyHint; use a non-zero value for persistent hints.

      Returns void

    • Changes native HUD visibility for this player; hide and show calls are reference-counted on the client.

      Parameters

      • visible: boolean

        True to show the HUD; false to hide it.

      Returns void

    • Shows a temporary native HUD message to this player.

      Parameters

      • text: string

        Message displayed on the player's top HUD message line.

      • durationSeconds: number

        How long the message remains visible, in seconds.

      Returns void

    • Shows the native multiple-choice question UI. The result is emitted as playerQuestionAnswer with a one-based answer index.

      Parameters

      • questionId: number

        Opaque caller-defined ID echoed by the playerQuestionAnswer event.

      • question: string

        Question text shown to the player.

      • answers: string[]

        One to four answer labels; entries beyond the fourth are ignored.

      • timeoutSeconds: number

        Time before the prompt is dismissed automatically.

      Returns void

    • Respawns this player at a world-space position.

      Parameters

      • x: number

        Respawn world-space X coordinate.

      • y: number

        Respawn world-space Y coordinate.

      • z: number

        Respawn world-space Z coordinate.

      Returns void

    • Starts the native lockpicking minigame. Completion, failure, or escape is emitted as playerLockpickResult.

      Parameters

      • id: number

        Opaque caller-defined ID echoed by the playerLockpickResult event.

      • pins: number

        Difficulty from 1 through 5 pins.

      • maxFails: number

        Allowed broken pins before failure; zero or less means unlimited attempts.

      Returns void

    • Sets, shows, and starts the player's native countdown timer.

      Parameters

      • seconds: number

        Initial countdown duration in seconds.

      Returns void

    • Returns a readable representation of this player.

      Returns string

      The player ID and nickname formatted for logging or debugging.

    discordId: string
    hardwareId: string
    id: number
    ip: string
    model: number

    Current shared player-model registry index, or -1 when unset or unknown.

    modelColor: number

    Current per-model palette variant, or -1 for the default.

    nickname: string

    Current connected-player nickname.

    ping: number
    position: Vector3
    rotation: Vector3 | Quaternion
    steamId: string
    virtualWorld: number