M2O Scripting APIScripting reference
    Preparing search index…
    Global objectServer API

    World

    World: {
        players: EntityCollection<Player>;
        vehicles: EntityCollection<Vehicle>;
        cycleTrafficLights(): number;
        getDrivingCoeff(): number;
        getDrivingMode(): "arcade" | "simulation" | "custom";
        getRainIntensity(): number;
        getTime(): WorldTime;
        getTimeNormalized(): number;
        getTimeScale(): number;
        getTrafficEpoch(): number;
        getWeather(): string;
        policeDispatch(
            event: string | number,
            x?: number,
            y?: number,
            z?: number,
            range?: number,
        ): void;
        setDrivingMode(mode: number | "arcade" | "simulation"): void;
        setRainIntensity(value: number): void;
        setTime(hour: number, minute?: number): void;
        setTimeScale(scale: number): void;
        setWeather(templateName: string): void;
    }

    Controls replicated world state and exposes collections of connected players and spawned vehicles.

    Type Declaration

    • Readonlyplayers: EntityCollection<Player>

      Connected players visible to scripts, indexed by network entity ID.

    • Readonlyvehicles: EntityCollection<Vehicle>

      Spawned vehicles visible to scripts, indexed by network entity ID.

    • cycleTrafficLights: function
      • Advances the replicated traffic-light cycle by one epoch.

        Returns number

        The new monotonically increasing traffic epoch.

    • getDrivingCoeff: function
      • Returns the replicated arcade driving coefficient.

        Returns number

        A value from 0 for simulation handling to 1 for arcade handling.

    • getDrivingMode: function
      • Returns the named driving-mode category for the current coefficient.

        Returns "arcade" | "simulation" | "custom"

        Arcade at coefficient 1, simulation at 0, or custom for an intermediate value.

    • getRainIntensity: function
      • Returns the replicated rain-intensity override.

        Returns number

        A value from 0 to 100, or -1 when no override is active.

    • getTime: function
    • getTimeNormalized: function
      • Returns the current game time in the engine's normalized representation.

        Returns number

        A value from 0 inclusive to 1 exclusive, where 0 is midnight and 0.5 is noon.

    • getTimeScale: function
      • Returns the current game-clock speed multiplier.

        Returns number

        The non-negative replicated time scale.

    • getTrafficEpoch: function
      • Returns the current replicated traffic-light epoch.

        Returns number

        The current traffic cycle counter.

    • getWeather: function
      • Returns the active replicated weather template.

        Returns string

        The configured template name, or an empty string when world state is unavailable.

    • policeDispatch: function
      • Broadcasts a police radio event globally or around a world-space position.

        Parameters

        • event: string | number

          Police radio event name or numeric event identifier.

        • Optionalx: number

          Optional world-space X coordinate; all four location arguments must be supplied together.

        • Optionaly: number

          Optional world-space Y coordinate.

        • Optionalz: number

          Optional world-space Z coordinate.

        • Optionalrange: number

          Optional dispatch radius around the supplied position.

        Returns void

    • setDrivingMode: function
      • Sets the replicated vehicle driving model.

        Parameters

        • mode: number | "arcade" | "simulation"

          Arcade, simulation (or sim), or a custom arcade coefficient from 0 to 1; numeric values are clamped.

        Returns void

    • setRainIntensity: function
      • Sets or disables the replicated rain-intensity override.

        Parameters

        • value: number

          Rain override from 0 to 100; a negative value disables the override.

        Returns void

    • setTime: function
      • Sets the replicated game time.

        Parameters

        • hour: number

          Hour of day; the combined time is clamped to the valid 24-hour range.

        • Optionalminute: number

          Minute of the hour; defaults to zero.

        Returns void

    • setTimeScale: function
      • Sets how quickly replicated game time advances.

        Parameters

        • scale: number

          Game-clock speed multiplier; negative values are clamped to zero.

        Returns void

    • setWeather: function
      • Sets the active replicated weather template.

        Parameters

        • templateName: string

          Mafia II weather template name to replicate to clients.

        Returns void