Skip to content
M2O Scripting APIScripting reference
Global objectServer APIGenerated

World

const World: object

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

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

readonly players: EntityCollection<Player>

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

readonly vehicles: EntityCollection<Vehicle>

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

cycleTrafficLights(): number

Advances the replicated traffic-light cycle by one epoch.

number

The new monotonically increasing traffic epoch.

getDrivingCoeff(): number

Returns the replicated arcade driving coefficient.

number

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

getDrivingMode(): "arcade" | "simulation" | "custom"

Returns the named driving-mode category for the current coefficient.

"arcade" | "simulation" | "custom"

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

getRainIntensity(): number

Returns the replicated rain-intensity override.

number

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

getTime(): WorldTime

Returns the current replicated game time as clock components.

WorldTime

The current hour and minute.

getTimeNormalized(): number

Returns the current game time in the engine’s normalized representation.

number

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

getTimeScale(): number

Returns the current game-clock speed multiplier.

number

The non-negative replicated time scale.

getTrafficEpoch(): number

Returns the current replicated traffic-light epoch.

number

The current traffic cycle counter.

getWeather(): string

Returns the active replicated weather template.

string

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

policeDispatch(event, x?, y?, z?, range?): void

Broadcasts a police radio event globally or around a world-space position.

string | number

Police radio event name or numeric event identifier.

number

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

number

Optional world-space Y coordinate.

number

Optional world-space Z coordinate.

number

Optional dispatch radius around the supplied position.

void

setDrivingMode(mode): void

Sets the replicated vehicle driving model.

number | "arcade" | "simulation"

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

void

setRainIntensity(value): void

Sets or disables the replicated rain-intensity override.

number

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

void

setTime(hour, minute?): void

Sets the replicated game time.

number

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

number

Minute of the hour; defaults to zero.

void

setTimeScale(scale): void

Sets how quickly replicated game time advances.

number

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

void

setWeather(templateName): void

Sets the active replicated weather template.

string

Mafia II weather template name to replicate to clients.

void