Open Road MP

Types

Every type of the API with its fields.

Every type of the API. In TypeScript they are in the namespace OpenRoadMP, e.g. OpenRoadMP.Player.

Weather

type Weather = "clear" | "rain"

The weather of mp.players.setWeather / mp.world.setWeather: clear (dry, sunny or cloudy) or rain.

MarkerIcon

type MarkerIcon = "flag" | "none" | "question" | "rest" | "fuel" | "service" | "garage" | "weigh" | "dealer" | "recruitment" | "buy" | "ferry" | "train" | "toll" | "border" | "viewpoint" | "ring"

The symbol of a world marker's hologram (the game's own): flag (default), none (only the brackets and the ring), question, rest (bed), fuel, service (wrench), garage, weigh (scales), dealer, recruitment, buy (euro), ferry (anchor), train, toll, border, viewpoint, ring (only the ring on the ground, no brackets or symbol).

UiElement

type UiElement = { readonly type: string }

A building block made with ui.* (e.g. ui.button(...)).

UiChild

type UiChild = UiElement | string | number | false | null | undefined

What a container takes: elements, text (shown as ui.text), or nothing (false/null/undefined are skipped, for conditions).

UiValues

type UiValues = Readonly<Record<string, string | number | boolean>>

The current values of all inputs of the view, by their id.

UiHandler

type UiHandler = (player: Player, values: UiValues) => void

Called in the gamemode when the player clicks or changes something.

CompanyAction

type CompanyAction = (player: PlayerRef) => void

company.add / company.remove: takes a player or a player id.

StorageValue

type StorageValue = null | boolean | number | string | StorageValue[] | { [key: string]: StorageValue }

What mp.storage keeps: anything JSON can hold.

Store

type Store = {
      /** The value, or undefined. A copy - change it and set() it again. */
      get(key: string): StorageValue | undefined
      /** Saves a value (undefined deletes it). Written to disk within a second. */
      set(key: string, value: StorageValue | undefined): void
      delete(key: string): void
      has(key: string): boolean
      keys(): string[]
    }

A key-value store of mp.storage (keys: 1-100 characters).

Zone

type Zone = {
      readonly id: number
      readonly name: string
      /** Middle; change it to move the zone. */
      center: Vector3
      /** Radius in metres (on the ground, x/z) */
      radius: number
      /** Height of the zone in metres around center.y; 0 = any height */
      height: number
      /** Players in the zone right now */
      readonly players: readonly Player[]
      contains(position: Vector3): boolean
      /** Deletes the zone (players in it get playerLeaveZone). */
      remove(): void
    }

An area made with mp.zones.create. Players in it get playerEnterZone / playerLeaveZone (checked about once a second).

ChatHandler

type ChatHandler = (player: Player, text: string) => string | false | void

mp.chat.onMessage: return false to drop the message, a string to send that instead, nothing to send it as it is.

PlaceType

type PlaceType = "fuel" | "service" | "dealer" | "garage" | "recruitment" | "weighStation" | "parking" | "viewpoint" | "ferry"

Kinds of places on the map (mp.world.places).

MapMarker

type MapMarker = {
      readonly id: number
      /** Where it is; change it to move the marker. */
      position: MapPoint
      label: string
      /** "#rrggbb" */
      color: string
      remove(): void
    }

A marker on the server's live map (mp.map.addMarker).

WorldMarker

type WorldMarker = {
      readonly id: number
      /** Where it is; change it to move the marker for everyone who sees it. */
      position: MapPoint | Vector3
      label: string
      /** "#rrggbb" */
      color: string
      /** Metres from the player's truck within which it is shown (10-100000). */
      range: number
      /** The label is seen through everything (else buildings and terrain hide it). */
      throughObjects: boolean
      /** false: no label, only the hologram. */
      showLabel: boolean
      /** The symbol in the hologram. */
      icon: MarkerIcon
      remove(): void
    }

A marker in the players' 3D world (mp.markers.add).

Vector3

World coordinates in metres: x = east, y = up, z = south.

FieldTypeDescription
xnumber
ynumber
znumber

Damage

Truck wear from 0 (new) to 1 (broken), as shown by the game's truck diagnostics.

FieldTypeDescription
enginenumber(read-only)
transmissionnumber(read-only)
cabinnumber(read-only)
chassisnumber(read-only)

JobPlace

One end of a job: city and company, display names as the player's game shows them plus the game's ids.

FieldTypeDescription
citystringe.g. "Berlin" (read-only)
cityIdstringe.g. "berlin" (read-only)
companystringe.g. "Tradeaux" (read-only)
companyIdstringe.g. "tradeaux" (read-only)

Job

The player's active job, as the game describes it.

FieldTypeDescription
cargostringCargo name in the player's game language, e.g. "Äpfel" (read-only)
cargoIdstringe.g. "apples" (read-only)
cargoMassnumberkg (read-only)
sourceJobPlace(read-only)
destinationJobPlace(read-only)
incomenumberPayment in euro (read-only)
distanceKmnumberPlanned distance (read-only)
deliveryTimenumberDeadline in game minutes since the profile started (0 = none) (read-only)
marketstring"cargo_market", "freight_market", "quick_job", "external_contracts" ... (read-only)
specialbooleanSpecial transport (read-only)
loadedbooleanCargo picked up (read-only)

Radio

What the player listens to.

FieldTypeDescription
source"music" | "internet" | "offline"Own music, internet radio or the game's offline stations (read-only)
stationstringStation (or track) name (read-only)

CommandInfo

A chat command of a gamemode on this server.

FieldTypeDescription
namestringwithout the /, e.g. "hilfe" (read-only)
helpstringShort description for help lists (read-only)
gamemodestringGamemode that answers it (read-only)

Player

A connected player. Position and speed are updated every second.

FieldTypeDescription
idnumber(read-only)
namestring(read-only)
accountIdstringThe player's Open Road MP account, e.g. "oprmp:KXQTRB-4821" - the same on every server and under any name, confirmed by the master server. Use it for admin rights, bans and saved progress. (read-only)
teamstring | nullThe player is in the Open Road MP team: the key of their role on openroadmp.com (e.g. "admin", "moderator" - the team can create more roles), else null. (read-only)
readybooleanThe player's game has loaded the world (after playerReady). Before that the player is connected but still loading: teleports, vehicles and markers are better done from playerReady. (read-only)
isAdminbooleanThe player's account ID is in admins of server.cfg: every right (also every mp.roles check). (read-only)
ghostbooleanmp.players.setGhost: drives through everyone (read-only)
visiblebooleanfalse after mp.players.setVisible(player, false): the others do not see this player (read-only)
language"de" | "en"Language of the player's Open Road MP UI (picked in the setup or the settings). Use it to word your own messages. (read-only)
moneynumber | nullBank balance in euro, updated every second; null for players with an older client (read-only)
companyCompany | nullThe player's company in this gamemode (mp.companies), null = none: the game then shows no company. Every player starts without a company. (read-only)
positionVector3 | nullnull while the player is not in the world yet (read-only)
headingnumberDriving direction in degrees, 0 = north, counter-clockwise (read-only)
speednumberkm/h, negative when reversing (read-only)
truckstringBrand and model of the current truck, e.g. "DAF XG+" (empty until known) (read-only)
damageDamageWear of the current truck, updated every few seconds (read-only)
vehicleVehicleStateGauges and switches of the truck: gear, rpm, fuel, lights, cruise control ... (read-only)
jobJob | nullActive job, null without one (updated within a few seconds) (read-only)
radioRadio | nullnull while the radio is off (read-only)

Fine

FieldTypeDescription
offenceOffence
labelstringGerman display name of the offence, e.g. "Geblitzt"
amountnumberEuro the game charged (0 when the fines rule is off)

ServerInfo

FieldTypeDescription
namestring(read-only)
motdstring(read-only)
maxPlayersnumber(read-only)
gamestring(read-only)

JobDelivered

A completed freight job of the game.

FieldTypeDescription
revenuenumberIncome in euro (game attribute revenue)
earnedXpnumberExperience points (game attribute earned.xp)
cargoDamagenumberCargo damage 0..1 (game attribute cargo.damage)
distanceKmnumberDistance driven (game attribute distance.km)
deliveryTimenumberDriving time in game minutes (game attribute delivery.time)
autoParkUsedbooleanAuto parking was used (game attribute auto.park.used)
autoLoadUsedbooleanAuto loading was used (game attribute auto.load.used)

JobCancelled

FieldTypeDescription
penaltynumberCancellation penalty in euro (game attribute cancel.penalty)

TollPaid

FieldTypeDescription
amountnumberToll in euro (game attribute pay.amount)

Transport

Ferry or train.

FieldTypeDescription
amountnumberPrice in euro (game attribute pay.amount)
sourceIdstringDeparture port or station (id) (game attribute source.id)
sourceNamestring(game attribute source.name)
targetIdstring(game attribute target.id)
targetNamestring(game attribute target.name)

SpecialJobDone

Car transport or bus job (newer game content).

FieldTypeDescription
earnedXpnumber(game attribute earned.xp)
cargoDamagenumber(game attribute cargo.damage)
vehicleDamagenumber(game attribute vehicle.damage)
passengerSatisfactionnumber(game attribute passenger.satisfaction)
distanceKmnumber(game attribute distance.km)
deliveryTimenumber(game attribute delivery.time)

TruckInfo

A truck a player can get with players.setVehicle (see mp.vehicles.trucks()).

FieldTypeDescription
nameTruckNameModel ("scania_s_2016") or dealer variant ("scania_s_2016/scania_s2016_8x4_770") (read-only)
brandstringe.g. "Scania" (read-only)
modelstringe.g. "S" or "FH (2021)" (read-only)
axlesstringe.g. "4x2", "6x2", "8x4" (read-only)
enginestringEngine as named in the game files, e.g. "DC16 770" (read-only)
dlcstring | nullArchive of a truck update (free with the game), null = base game (read-only)

JobPlaceRef

One end of a job to assign, as the game's ids (the same as Job.source.companyId / cityId).

FieldTypeDescription
companystringCompany id, e.g. "tradeaux"
citystringCity id, e.g. "berlin"

JobSpec

A freight market job to assign (see JobBuilder).

FieldTypeDescription
cargostringCargo id, e.g. "apples" (as Job.cargoId)
sourceJobPlaceRefWhere the trailer waits
destinationJobPlaceRefWhere it goes
incomenumberPayment in euro on delivery. Without it the game calculates the payment. (optional)

Mail

A mail for the game's mail screen (desktop menu Mail). Plain text: a line break starts a new line, < and > are shown as ( and ).

FieldTypeDescription
fromstringSender, at most 60 characters. Default: the server's name. (optional)
subjectstringSubject, at most 120 characters. (optional)
bodystringThe text, at most 4000 characters. (optional)

UiViewOptions

Options of a UiView.

FieldTypeDescription
titlestringShown at the top of a window (optional)
descriptionstringSmaller text below the title (optional)
size"sm" | "md" | "lg" | "xl"Width of a window. Default "md". (optional)
mode"window" | "hud""window" (default): in the middle of the screen, with the mouse; the game gets no input until it is closed. "hud": a panel over the game that does not take the mouse (scoreboards, timers). (optional)
position"top" | "bottom" | "left" | "right" | "top-left" | "top-right" | "bottom-left" | "bottom-right"Where a "hud" panel sits. Default "top-right". (optional)
closablebooleanA window can be closed with its X and Escape. Default true. (optional)

UiStackProps

Children one below the other.

FieldTypeDescription
gapnumberSpace between the children, 0 to 12 (steps of 4 px). Default 3. (optional)
align"start" | "center" | "end" | "stretch"Horizontal alignment. Default "stretch". (optional)

UiRowProps

Children side by side.

FieldTypeDescription
gapnumberSpace between the children, 0 to 12 (steps of 4 px). Default 3. (optional)
align"start" | "center" | "end"Vertical alignment. Default "center". (optional)
justify"start" | "center" | "end" | "between"Default "start". (optional)
wrapbooleanWrap into the next line when there is no room. (optional)

UiGridProps

Children in a grid.

FieldTypeDescription
columnsnumber1 to 6
gapnumberSpace between the children, 0 to 12 (steps of 4 px). Default 3. (optional)

UiCardProps

A framed card.

FieldTypeDescription
titlestring(optional)
descriptionstring(optional)
footerUiChild []Shown at the bottom, e.g. buttons (optional)

UiTextProps

FieldTypeDescription
tone"default" | "muted" | "primary" | "success" | "warning" | "danger"(optional)
size"sm" | "md" | "lg"(optional)
boldboolean(optional)
align"left" | "center" | "right"(optional)

UiHeadingProps

FieldTypeDescription
level1 | 2 | 31 = largest. Default 2. (optional)

UiBadgeProps

FieldTypeDescription
variant"default" | "secondary" | "outline" | "destructive"(optional)

UiAlertProps

FieldTypeDescription
titlestring
descriptionstring(optional)
variant"default" | "destructive"(optional)

UiProgressProps

FieldTypeDescription
valuenumber
maxnumberDefault 100 (optional)
labelstring(optional)

UiTableProps

FieldTypeDescription
columnsstring[]Column headings
rowsUiChild [][]One array per row, one entry per column

UiSection

A tab or an accordion item.

FieldTypeDescription
titlestring
contentUiChild []

UiTabsProps

FieldTypeDescription
tabsUiSection []

UiAccordionProps

FieldTypeDescription
itemsUiSection []

UiButtonProps

FieldTypeDescription
labelstring
variant"default" | "secondary" | "outline" | "ghost" | "destructive"(optional)
size"sm" | "md" | "lg"(optional)
disabledboolean(optional)
onClickUiHandlerRuns in the gamemode when the player clicks; gets the values of all inputs of the view (optional)
closebooleanClose the view after the click (optional)

UiInputProps

FieldTypeDescription
idstringKey of its value in UiValues
labelstring(optional)
placeholderstring(optional)
valuestringStart value (optional)
type"text" | "number" | "password"(optional)
maxLengthnumberDefault 100 (optional)
onSubmitUiHandlerEnter in the field (optional)

UiTextareaProps

FieldTypeDescription
idstring
labelstring(optional)
placeholderstring(optional)
valuestring(optional)
rowsnumber(optional)
maxLengthnumberDefault 250 (optional)

UiOption

An entry of a select or radio group.

FieldTypeDescription
valuestring
labelstring

UiSelectProps

FieldTypeDescription
idstring
labelstring(optional)
optionsArray <string | UiOption >
valuestring(optional)
placeholderstring(optional)
onChangeUiHandler(optional)

UiCheckProps

A checkbox or switch.

FieldTypeDescription
idstring
labelstring
checkedboolean(optional)
onChangeUiHandler(optional)

UiRadioProps

FieldTypeDescription
idstring
labelstring(optional)
optionsArray <string | UiOption >
valuestring(optional)
onChangeUiHandler(optional)

UiSliderProps

FieldTypeDescription
idstring
labelstring(optional)
minnumber
maxnumber
stepnumberDefault 1 (optional)
valuenumber(optional)
onChangeUiHandlerRuns when the player lets go (optional)

UiLogoPickerProps

FieldTypeDescription
idstring
labelstring(optional)
valuenumberThe selected logo, 0-15 (as mp.companies' logo). Default 0 (optional)
onChangeUiHandlerRuns when the player picks a logo (optional)

CompanyInit

What mp.companies.create takes.

FieldTypeDescription
namestringShown in the game's top bar instead of the player's own company, 1-40 characters.
logonumberOne of the game's 16 company logos, 0-15 (material/ui/player_logo/logo_<n>). Default 0. (optional)

Company

A company of your gamemode (mp.companies.create). Its members see its name and logo in the game as their own company. Changing name or logo applies to every member right away. Companies live as long as the gamemode runs.

FieldTypeDescription
idnumber(read-only)
namestring1-40 characters
logonumber0-15
membersPlayer []Online players in this company (read-only)
addCompanyActionPuts the player into this company (out of any other). (read-only)
removeCompanyActionTakes the player out of this company: no company again. (read-only)

ZoneInit

What mp.zones.create takes.

FieldTypeDescription
namestringFor your own use and the log (optional)
centerVector3
radiusnumberMetres, on the ground (x/z)
heightnumberMetres around center.y; leave out for any height (optional)

Ban

A ban by Open Road MP account (mp.bans).

FieldTypeDescription
accountIdstring(read-only)
untilnumber | nullWhen it ends (milliseconds since 1970, like Date.now()); null = for ever (read-only)
reasonstring(read-only)

BanOptions

What mp.bans.add takes besides the player.

FieldTypeDescription
minutesnumberHow long; leave out for ever (optional)
reasonstringShown to the player when they try to join, at most 120 characters (optional)

CommandOptions

Optional fourth argument of mp.commands.add.

FieldTypeDescription
rolestringOnly players with this role (mp.roles) may use the command; admins always may. Others get a short "no permission" answer. (optional)

MapPoint

A point on the map: x to the east, z to the south, in metres (like position, without the height).

FieldTypeDescription
xnumber
znumber

City

A city on the map (mp.world).

FieldTypeDescription
idstringGame id, e.g. "berlin" - as in job.source.cityId (read-only)
namestringDisplay name (English), e.g. "Berlin" (read-only)
countrystringCountry id, e.g. "germany"; "" without gamedata.json (read-only)
populationnumberAs on the game's map; 0 if unknown (read-only)
dlcstringMap DLC it belongs to; "" = base game (read-only)
positionMapPoint(read-only)

CompanySite

A company depot on the map (mp.world.companies) - the places of the game's jobs.

FieldTypeDescription
idstringCompany id, e.g. "tradeaux" - as in job.source.companyId (read-only)
namestring(read-only)
citystringCity id (read-only)
positionMapPoint(read-only)
spawnCompanySpawn | nullWhere a truck is put at the depot (mp.players.teleportToCompany); null for the few depots without one (read-only)
sendsstring[]Cargo ids it sends (for JobBuilder) (read-only)
acceptsstring[]Cargo ids it accepts (read-only)
dlcstring(read-only)

Place

A fuel station, service, dealer ... (mp.world.places).

FieldTypeDescription
typePlaceType(read-only)
namestringOften empty; brand for dealers (read-only)
positionMapPoint(read-only)

CargoInfo

A cargo of the game (mp.world.cargo).

FieldTypeDescription
idstringe.g. "apples" - as in JobBuilder.cargo (read-only)
groupsstring[](read-only)
bodiesstring[]Trailer bodies that carry it (read-only)
massnumberkg per unit (read-only)
volumenumber(read-only)
fragilitynumber0-1 (read-only)
adrnumberADR class, 0 = none (read-only)
dlcstring(read-only)

MarkerInit

What mp.map.addMarker takes.

FieldTypeDescription
positionMapPointA MapPoint or any Vector3 (e.g. player.position)
labelstringAt most 80 characters (optional)
colorstring"#rrggbb", default orange (optional)

WorldMarkerInit

What mp.markers.add takes.

FieldTypeDescription
positionMapPoint | Vector3Where in the world, in metres. Without y it floats at the height of each player's own truck - for points on the map; with y (e.g. player.position) at that height
labelstringAt most 80 characters, shown with the distance (optional)
colorstring"#rrggbb", default orange. The label takes it exactly, the hologram the nearest of green, blue, red, orange, yellow, purple, pink, cyan and white (optional)
playersPlayerRef []Only these players see it, e.g. [player]; leave out for everyone (also those who join later). Fixed when the marker is created (optional)
rangenumberShown only within this many metres of the player's truck (10 to 100000, default 100); it fades out at the edge (optional)
throughObjectsbooleantrue: the label is seen through everything - for destinations far away; default false: buildings, bridges and terrain between the camera and the label hide it (the game's physics decides; vehicles do not hide it). The hologram is part of the world either way (optional)
showLabelbooleanfalse: no label, only the hologram; default true (optional)
iconMarkerIconThe symbol in the hologram, default "flag"; "none" leaves the middle empty (only the corner brackets and the ring on the ground), "ring" shows only the ring on the ground (optional)

Notice

A notice at the top of a player's HUD (mp.ui.notify).

FieldTypeDescription
titlestringAt most 120 characters
textstringAt most 300 characters (optional)
kind"info" | "warning" | "alert"Colour and icon; default info (optional)
secondsnumberHow long it stays; default 5, 0 = until the player leaves the world (optional)

VehicleState

The gauges and switches of a player's truck, updated every second. Gear, rpm, fuel, odometer, cruise control, speed limit, parking brake, cargo damage and route are missing for players with an older client.

FieldTypeDescription
engineOnboolean(read-only)
gearnumber> 0 forward, < 0 reverse, 0 neutral (optional, read-only)
rpmnumber(optional, read-only)
fuelnumberLitres in the tank (optional, read-only)
fuelCapacitynumberTank size in litres (optional, read-only)
fuelRangenumberkm the fuel lasts at the average consumption (0 = unknown) (optional, read-only)
odometernumberkm on the clock (optional, read-only)
cruiseControlnumberSet speed in km/h, 0 = off (optional, read-only)
speedLimitnumberSpeed limit of the road in km/h, 0 = none (optional, read-only)
parkingBrakeboolean(optional, read-only)
trailerAttachedboolean(read-only)
cargoDamagenumberDamage of the attached trailer's cargo, 0..1 (optional, read-only)
lightsVehicleLights(read-only)
wipersboolean(read-only)
routeRoute | nullThe navigation's route, null without one (optional, read-only)

VehicleLights

Light switches of a truck.

FieldTypeDescription
lowbooleanLow beam (read-only)
highbooleanHigh beam (read-only)
parkingboolean(read-only)
beaconboolean(read-only)
hazardbooleanHazard warning lights (read-only)

Route

What the navigation shows for its route.

FieldTypeDescription
distanceKmnumberRemaining distance (read-only)
minutesnumberEstimated driving time in real minutes (read-only)

CompanySpawn

A place at a company depot for a truck: on the ground, facing into the yard.

FieldTypeDescription
positionVector3(read-only)
headingnumberDegrees, 0 = north (read-only)

On this page