Open Road MP

mp.world

The map: cities, company depots, fuel stations and more, cargo - and the time of day.

cities

mp.world.cities(): readonly City[]

Every city of the map (with the server's map DLCs).

Types: City

city

mp.world.city(id: string): City | undefined

A city by id, or undefined.

Types: City

companies

mp.world.companies(filter?: { id?: string; city?: string }): readonly CompanySite[]

Every company depot, optionally of one company or in one city.

Types: CompanySite

company

mp.world.company(id: string, city: string): CompanySite | undefined

A depot by company id and city id, or undefined.

Types: CompanySite

places

mp.world.places(type?: PlaceType): readonly Place[]

Fuel stations, services, dealers, garages ... - all, or of one kind.

Types: PlaceType, Place

cargo

mp.world.cargo(): readonly CargoInfo[]

Every cargo of the game (needs gamedata.json next to the server).

Types: CargoInfo

countries

mp.world.countries(): readonly string[]

The country ids that have cities (needs gamedata.json).

nearestCity

mp.world.nearestCity(position: MapPoint): City | undefined

The city closest to a point (e.g. player.position).

Types: MapPoint, City

nearestCompany

mp.world.nearestCompany(position: MapPoint, id?: string): CompanySite | undefined

The company depot closest to a point, optionally of one company.

Types: MapPoint, CompanySite

nearestPlace

mp.world.nearestPlace(position: MapPoint, type: PlaceType): Place | undefined

The place of a kind closest to a point, e.g. the next fuel station.

Types: MapPoint, PlaceType, Place

distance

mp.world.distance(a: MapPoint, b: MapPoint): number

Straight-line distance in metres between two points (on the ground).

Types: MapPoint

setTime

mp.world.setTime(hour: number, minute?: number): void

Sets the time of day for every player online (each game keeps running from there).

setWeather

mp.world.setWeather(weather: Weather, smooth?: boolean): void

Sets the weather for every player online, like mp.players.setWeather. To keep it, set the rule badWeather as well (0 = always dry, 1 = always rain); players joining later get the weather of the rule.

Types: Weather

setSpawn

mp.world.setSpawn(spawn: (({ city: string } | { company: string; city: string } | { position: Vector3; heading?: number }) & { vehicle?: TruckName | (string & {}) }) | null): void

The standard spawn: where every player starts. Every session is a fresh career without a truck - the player presses "Drive" on the desktop, gets the fallback vehicle (vehicle here, else players.setFallbackVehicle / fallback_vehicle in server.cfg) and is put here; set it in your gamemode, or players start wherever the game puts them. { city } = a random depot of the city, { company, city } = that depot, { position, heading? } = a point (heading in degrees, 0 = north). Applied on playerReady, before your handlers. null = no spawn.

Types: Vector3

On this page