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 | undefinedWhat 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) => voidCalled in the gamemode when the player clicks or changes something.
CompanyAction
type CompanyAction = (player: PlayerRef) => voidcompany.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 | voidmp.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.
| Field | Type | Description |
|---|---|---|
x | number | |
y | number | |
z | number |
Damage
Truck wear from 0 (new) to 1 (broken), as shown by the game's truck diagnostics.
| Field | Type | Description |
|---|---|---|
engine | number | (read-only) |
transmission | number | (read-only) |
cabin | number | (read-only) |
chassis | number | (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.
| Field | Type | Description |
|---|---|---|
city | string | e.g. "Berlin" (read-only) |
cityId | string | e.g. "berlin" (read-only) |
company | string | e.g. "Tradeaux" (read-only) |
companyId | string | e.g. "tradeaux" (read-only) |
Job
The player's active job, as the game describes it.
| Field | Type | Description |
|---|---|---|
cargo | string | Cargo name in the player's game language, e.g. "Äpfel" (read-only) |
cargoId | string | e.g. "apples" (read-only) |
cargoMass | number | kg (read-only) |
source | JobPlace | (read-only) |
destination | JobPlace | (read-only) |
income | number | Payment in euro (read-only) |
distanceKm | number | Planned distance (read-only) |
deliveryTime | number | Deadline in game minutes since the profile started (0 = none) (read-only) |
market | string | "cargo_market", "freight_market", "quick_job", "external_contracts" ... (read-only) |
special | boolean | Special transport (read-only) |
loaded | boolean | Cargo picked up (read-only) |
Radio
What the player listens to.
| Field | Type | Description |
|---|---|---|
source | "music" | "internet" | "offline" | Own music, internet radio or the game's offline stations (read-only) |
station | string | Station (or track) name (read-only) |
CommandInfo
A chat command of a gamemode on this server.
| Field | Type | Description |
|---|---|---|
name | string | without the /, e.g. "hilfe" (read-only) |
help | string | Short description for help lists (read-only) |
gamemode | string | Gamemode that answers it (read-only) |
Player
A connected player. Position and speed are updated every second.
| Field | Type | Description |
|---|---|---|
id | number | (read-only) |
name | string | (read-only) |
accountId | string | The 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) |
team | string | null | The 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) |
ready | boolean | The 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) |
isAdmin | boolean | The player's account ID is in admins of server.cfg: every right (also every mp.roles check). (read-only) |
ghost | boolean | mp.players.setGhost: drives through everyone (read-only) |
visible | boolean | false 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) |
money | number | null | Bank balance in euro, updated every second; null for players with an older client (read-only) |
company | Company | null | The player's company in this gamemode (mp.companies), null = none: the game then shows no company. Every player starts without a company. (read-only) |
position | Vector3 | null | null while the player is not in the world yet (read-only) |
heading | number | Driving direction in degrees, 0 = north, counter-clockwise (read-only) |
speed | number | km/h, negative when reversing (read-only) |
truck | string | Brand and model of the current truck, e.g. "DAF XG+" (empty until known) (read-only) |
damage | Damage | Wear of the current truck, updated every few seconds (read-only) |
vehicle | VehicleState | Gauges and switches of the truck: gear, rpm, fuel, lights, cruise control ... (read-only) |
job | Job | null | Active job, null without one (updated within a few seconds) (read-only) |
radio | Radio | null | null while the radio is off (read-only) |
Fine
| Field | Type | Description |
|---|---|---|
offence | Offence | |
label | string | German display name of the offence, e.g. "Geblitzt" |
amount | number | Euro the game charged (0 when the fines rule is off) |
ServerInfo
| Field | Type | Description |
|---|---|---|
name | string | (read-only) |
motd | string | (read-only) |
maxPlayers | number | (read-only) |
game | string | (read-only) |
JobDelivered
A completed freight job of the game.
| Field | Type | Description |
|---|---|---|
revenue | number | Income in euro (game attribute revenue) |
earnedXp | number | Experience points (game attribute earned.xp) |
cargoDamage | number | Cargo damage 0..1 (game attribute cargo.damage) |
distanceKm | number | Distance driven (game attribute distance.km) |
deliveryTime | number | Driving time in game minutes (game attribute delivery.time) |
autoParkUsed | boolean | Auto parking was used (game attribute auto.park.used) |
autoLoadUsed | boolean | Auto loading was used (game attribute auto.load.used) |
JobCancelled
| Field | Type | Description |
|---|---|---|
penalty | number | Cancellation penalty in euro (game attribute cancel.penalty) |
TollPaid
| Field | Type | Description |
|---|---|---|
amount | number | Toll in euro (game attribute pay.amount) |
Transport
Ferry or train.
| Field | Type | Description |
|---|---|---|
amount | number | Price in euro (game attribute pay.amount) |
sourceId | string | Departure port or station (id) (game attribute source.id) |
sourceName | string | (game attribute source.name) |
targetId | string | (game attribute target.id) |
targetName | string | (game attribute target.name) |
SpecialJobDone
Car transport or bus job (newer game content).
| Field | Type | Description |
|---|---|---|
earnedXp | number | (game attribute earned.xp) |
cargoDamage | number | (game attribute cargo.damage) |
vehicleDamage | number | (game attribute vehicle.damage) |
passengerSatisfaction | number | (game attribute passenger.satisfaction) |
distanceKm | number | (game attribute distance.km) |
deliveryTime | number | (game attribute delivery.time) |
TruckInfo
A truck a player can get with players.setVehicle (see mp.vehicles.trucks()).
| Field | Type | Description |
|---|---|---|
name | TruckName | Model ("scania_s_2016") or dealer variant ("scania_s_2016/scania_s2016_8x4_770") (read-only) |
brand | string | e.g. "Scania" (read-only) |
model | string | e.g. "S" or "FH (2021)" (read-only) |
axles | string | e.g. "4x2", "6x2", "8x4" (read-only) |
engine | string | Engine as named in the game files, e.g. "DC16 770" (read-only) |
dlc | string | null | Archive 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).
| Field | Type | Description |
|---|---|---|
company | string | Company id, e.g. "tradeaux" |
city | string | City id, e.g. "berlin" |
JobSpec
A freight market job to assign (see JobBuilder).
| Field | Type | Description |
|---|---|---|
cargo | string | Cargo id, e.g. "apples" (as Job.cargoId) |
source | JobPlaceRef | Where the trailer waits |
destination | JobPlaceRef | Where it goes |
income | number | Payment in euro on delivery. Without it the game calculates the payment. (optional) |
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 ).
| Field | Type | Description |
|---|---|---|
from | string | Sender, at most 60 characters. Default: the server's name. (optional) |
subject | string | Subject, at most 120 characters. (optional) |
body | string | The text, at most 4000 characters. (optional) |
UiViewOptions
Options of a UiView.
| Field | Type | Description |
|---|---|---|
title | string | Shown at the top of a window (optional) |
description | string | Smaller 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) |
closable | boolean | A window can be closed with its X and Escape. Default true. (optional) |
UiStackProps
Children one below the other.
| Field | Type | Description |
|---|---|---|
gap | number | Space 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.
| Field | Type | Description |
|---|---|---|
gap | number | Space 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) |
wrap | boolean | Wrap into the next line when there is no room. (optional) |
UiGridProps
Children in a grid.
| Field | Type | Description |
|---|---|---|
columns | number | 1 to 6 |
gap | number | Space between the children, 0 to 12 (steps of 4 px). Default 3. (optional) |
UiCardProps
A framed card.
| Field | Type | Description |
|---|---|---|
title | string | (optional) |
description | string | (optional) |
footer | UiChild [] | Shown at the bottom, e.g. buttons (optional) |
UiTextProps
| Field | Type | Description |
|---|---|---|
tone | "default" | "muted" | "primary" | "success" | "warning" | "danger" | (optional) |
size | "sm" | "md" | "lg" | (optional) |
bold | boolean | (optional) |
align | "left" | "center" | "right" | (optional) |
UiHeadingProps
| Field | Type | Description |
|---|---|---|
level | 1 | 2 | 3 | 1 = largest. Default 2. (optional) |
UiBadgeProps
| Field | Type | Description |
|---|---|---|
variant | "default" | "secondary" | "outline" | "destructive" | (optional) |
UiAlertProps
| Field | Type | Description |
|---|---|---|
title | string | |
description | string | (optional) |
variant | "default" | "destructive" | (optional) |
UiProgressProps
| Field | Type | Description |
|---|---|---|
value | number | |
max | number | Default 100 (optional) |
label | string | (optional) |
UiTableProps
| Field | Type | Description |
|---|---|---|
columns | string[] | Column headings |
rows | UiChild [][] | One array per row, one entry per column |
UiSection
A tab or an accordion item.
| Field | Type | Description |
|---|---|---|
title | string | |
content | UiChild [] |
UiTabsProps
| Field | Type | Description |
|---|---|---|
tabs | UiSection [] |
UiAccordionProps
| Field | Type | Description |
|---|---|---|
items | UiSection [] |
UiButtonProps
| Field | Type | Description |
|---|---|---|
label | string | |
variant | "default" | "secondary" | "outline" | "ghost" | "destructive" | (optional) |
size | "sm" | "md" | "lg" | (optional) |
disabled | boolean | (optional) |
onClick | UiHandler | Runs in the gamemode when the player clicks; gets the values of all inputs of the view (optional) |
close | boolean | Close the view after the click (optional) |
UiInputProps
| Field | Type | Description |
|---|---|---|
id | string | Key of its value in UiValues |
label | string | (optional) |
placeholder | string | (optional) |
value | string | Start value (optional) |
type | "text" | "number" | "password" | (optional) |
maxLength | number | Default 100 (optional) |
onSubmit | UiHandler | Enter in the field (optional) |
UiTextareaProps
| Field | Type | Description |
|---|---|---|
id | string | |
label | string | (optional) |
placeholder | string | (optional) |
value | string | (optional) |
rows | number | (optional) |
maxLength | number | Default 250 (optional) |
UiOption
An entry of a select or radio group.
| Field | Type | Description |
|---|---|---|
value | string | |
label | string |
UiSelectProps
| Field | Type | Description |
|---|---|---|
id | string | |
label | string | (optional) |
options | Array <string | UiOption > | |
value | string | (optional) |
placeholder | string | (optional) |
onChange | UiHandler | (optional) |
UiCheckProps
A checkbox or switch.
| Field | Type | Description |
|---|---|---|
id | string | |
label | string | |
checked | boolean | (optional) |
onChange | UiHandler | (optional) |
UiRadioProps
| Field | Type | Description |
|---|---|---|
id | string | |
label | string | (optional) |
options | Array <string | UiOption > | |
value | string | (optional) |
onChange | UiHandler | (optional) |
UiSliderProps
| Field | Type | Description |
|---|---|---|
id | string | |
label | string | (optional) |
min | number | |
max | number | |
step | number | Default 1 (optional) |
value | number | (optional) |
onChange | UiHandler | Runs when the player lets go (optional) |
UiLogoPickerProps
| Field | Type | Description |
|---|---|---|
id | string | |
label | string | (optional) |
value | number | The selected logo, 0-15 (as mp.companies' logo). Default 0 (optional) |
onChange | UiHandler | Runs when the player picks a logo (optional) |
CompanyInit
What mp.companies.create takes.
| Field | Type | Description |
|---|---|---|
name | string | Shown in the game's top bar instead of the player's own company, 1-40 characters. |
logo | number | One 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.
| Field | Type | Description |
|---|---|---|
id | number | (read-only) |
name | string | 1-40 characters |
logo | number | 0-15 |
members | Player [] | Online players in this company (read-only) |
add | CompanyAction | Puts the player into this company (out of any other). (read-only) |
remove | CompanyAction | Takes the player out of this company: no company again. (read-only) |
ZoneInit
What mp.zones.create takes.
| Field | Type | Description |
|---|---|---|
name | string | For your own use and the log (optional) |
center | Vector3 | |
radius | number | Metres, on the ground (x/z) |
height | number | Metres around center.y; leave out for any height (optional) |
Ban
A ban by Open Road MP account (mp.bans).
| Field | Type | Description |
|---|---|---|
accountId | string | (read-only) |
until | number | null | When it ends (milliseconds since 1970, like Date.now()); null = for ever (read-only) |
reason | string | (read-only) |
BanOptions
What mp.bans.add takes besides the player.
| Field | Type | Description |
|---|---|---|
minutes | number | How long; leave out for ever (optional) |
reason | string | Shown to the player when they try to join, at most 120 characters (optional) |
CommandOptions
Optional fourth argument of mp.commands.add.
| Field | Type | Description |
|---|---|---|
role | string | Only 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).
| Field | Type | Description |
|---|---|---|
x | number | |
z | number |
City
A city on the map (mp.world).
| Field | Type | Description |
|---|---|---|
id | string | Game id, e.g. "berlin" - as in job.source.cityId (read-only) |
name | string | Display name (English), e.g. "Berlin" (read-only) |
country | string | Country id, e.g. "germany"; "" without gamedata.json (read-only) |
population | number | As on the game's map; 0 if unknown (read-only) |
dlc | string | Map DLC it belongs to; "" = base game (read-only) |
position | MapPoint | (read-only) |
CompanySite
A company depot on the map (mp.world.companies) - the places of the game's jobs.
| Field | Type | Description |
|---|---|---|
id | string | Company id, e.g. "tradeaux" - as in job.source.companyId (read-only) |
name | string | (read-only) |
city | string | City id (read-only) |
position | MapPoint | (read-only) |
spawn | CompanySpawn | null | Where a truck is put at the depot (mp.players.teleportToCompany); null for the few depots without one (read-only) |
sends | string[] | Cargo ids it sends (for JobBuilder) (read-only) |
accepts | string[] | Cargo ids it accepts (read-only) |
dlc | string | (read-only) |
Place
A fuel station, service, dealer ... (mp.world.places).
| Field | Type | Description |
|---|---|---|
type | PlaceType | (read-only) |
name | string | Often empty; brand for dealers (read-only) |
position | MapPoint | (read-only) |
CargoInfo
A cargo of the game (mp.world.cargo).
| Field | Type | Description |
|---|---|---|
id | string | e.g. "apples" - as in JobBuilder.cargo (read-only) |
groups | string[] | (read-only) |
bodies | string[] | Trailer bodies that carry it (read-only) |
mass | number | kg per unit (read-only) |
volume | number | (read-only) |
fragility | number | 0-1 (read-only) |
adr | number | ADR class, 0 = none (read-only) |
dlc | string | (read-only) |
MarkerInit
What mp.map.addMarker takes.
| Field | Type | Description |
|---|---|---|
position | MapPoint | A MapPoint or any Vector3 (e.g. player.position) |
label | string | At most 80 characters (optional) |
color | string | "#rrggbb", default orange (optional) |
WorldMarkerInit
What mp.markers.add takes.
| Field | Type | Description |
|---|---|---|
position | MapPoint | Vector3 | Where 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 |
label | string | At most 80 characters, shown with the distance (optional) |
color | string | "#rrggbb", default orange. The label takes it exactly, the hologram the nearest of green, blue, red, orange, yellow, purple, pink, cyan and white (optional) |
players | PlayerRef [] | Only these players see it, e.g. [player]; leave out for everyone (also those who join later). Fixed when the marker is created (optional) |
range | number | Shown only within this many metres of the player's truck (10 to 100000, default 100); it fades out at the edge (optional) |
throughObjects | boolean | true: 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) |
showLabel | boolean | false: no label, only the hologram; default true (optional) |
icon | MarkerIcon | The 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).
| Field | Type | Description |
|---|---|---|
title | string | At most 120 characters |
text | string | At most 300 characters (optional) |
kind | "info" | "warning" | "alert" | Colour and icon; default info (optional) |
seconds | number | How 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.
| Field | Type | Description |
|---|---|---|
engineOn | boolean | (read-only) |
gear | number | > 0 forward, < 0 reverse, 0 neutral (optional, read-only) |
rpm | number | (optional, read-only) |
fuel | number | Litres in the tank (optional, read-only) |
fuelCapacity | number | Tank size in litres (optional, read-only) |
fuelRange | number | km the fuel lasts at the average consumption (0 = unknown) (optional, read-only) |
odometer | number | km on the clock (optional, read-only) |
cruiseControl | number | Set speed in km/h, 0 = off (optional, read-only) |
speedLimit | number | Speed limit of the road in km/h, 0 = none (optional, read-only) |
parkingBrake | boolean | (optional, read-only) |
trailerAttached | boolean | (read-only) |
cargoDamage | number | Damage of the attached trailer's cargo, 0..1 (optional, read-only) |
lights | VehicleLights | (read-only) |
wipers | boolean | (read-only) |
route | Route | null | The navigation's route, null without one (optional, read-only) |
VehicleLights
Light switches of a truck.
| Field | Type | Description |
|---|---|---|
low | boolean | Low beam (read-only) |
high | boolean | High beam (read-only) |
parking | boolean | (read-only) |
beacon | boolean | (read-only) |
hazard | boolean | Hazard warning lights (read-only) |
Route
What the navigation shows for its route.
| Field | Type | Description |
|---|---|---|
distanceKm | number | Remaining distance (read-only) |
minutes | number | Estimated driving time in real minutes (read-only) |
CompanySpawn
A place at a company depot for a truck: on the ground, facing into the yard.
| Field | Type | Description |
|---|---|---|
position | Vector3 | (read-only) |
heading | number | Degrees, 0 = north (read-only) |