Open Road MP

mp.players

Change a player's game and find players.

setMoney

mp.players.setMoney(player: PlayerRef, amount: number): void

Sets the player's bank balance in the game.

giveMoney

mp.players.giveMoney(player: PlayerRef, amount: number): void

Adds to the player's bank balance (negative: takes from it, never below 0). Unlike setMoney it cannot overwrite what the player earned a moment ago.

repair

mp.players.repair(player: PlayerRef): void

Repairs the player's truck, trailers and cargo completely (the game's own repair).

cancelJob

mp.players.cancelJob(player: PlayerRef): void

Cancels the player's active job (does nothing without one).

teleport

mp.players.teleport(player: PlayerRef, position: Vector3, heading?: number): void

Moves the player's truck to a position. heading in degrees (0 = north).

Types: Vector3

mp.players.navigateTo(player: PlayerRef, position: MapPoint | Vector3 | null): void

Sets the destination of the player's navigation: the game plans the route to the nearest road within 200 m and shows its flag on the map and the route advisor. null takes the destination away. One destination per player - a new one replaces it (also a job's route).

Types: MapPoint, Vector3

setExperience

mp.players.setExperience(player: PlayerRef, xp: number): void

Sets the player's experience points (0 to 100000000). The level follows from them.

setLevel

mp.players.setLevel(player: PlayerRef, level: number): void

Sets the player's level (0 to 1000). Fractions are the progress into the next level, e.g. 12.5.

setExploration

mp.players.setExploration(player: PlayerRef, percent: number): void

Sets how much of the map the player has explored, in percent (0 to 100): roads and visited cities.

setVehicle

mp.players.setVehicle(player: PlayerRef, name: TruckName | (string & {}), kind?: "truck" | "car" | "bus"): void

Replaces the player's vehicle with one defined in def/vehicle/<kind>_desktop/<name>.sii (or <kind>_cheat), e.g. "scania_s_2016" or "daf_2021". kind: "truck" (default), "car" or "bus". Names: lowercase letters, digits, _ . and /. Not possible while the player is on a job with another vehicle type.

setLicensePlate

mp.players.setLicensePlate(player: PlayerRef, text: string, country?: string): void

Sets the license plate of the player's truck and its trailers (memory only). text: 1-12 of A-Z, 0-9, space, - and . (lower case is turned upper case); country: a country of the game whose plate design is used, default "germany". Every player starts with "OR MP 2026"; the plate stays after /model.

setTime

mp.players.setTime(player: PlayerRef, hour: number, minute?: number): void

Sets the time of day in the player's game. The game's clock only runs forward: it jumps ahead to the next occurrence of that time. Nothing in between is simulated (unlike the game's own g_set_time, which plays the span through like sleeping). For the same time for everyone, use mp.world.setTime (as /time in freeroam does).

setWeather

mp.players.setWeather(player: PlayerRef, weather: Weather, smooth?: boolean): void

Sets the weather in the player's game: "clear" or "rain" (ETS2 knows only these two; thunderstorms come with rain by chance). It changes at once (smooth is accepted but has no effect: the game's interpolated change never brought the rain). The game rolls the next weather by itself later (after tens of minutes, depending on the rule badWeather): to keep it, also set the rule - badWeather 0 = never rain, 1 = always rain. For everyone, use mp.world.setWeather.

Types: Weather

setFallbackVehicle

mp.players.setFallbackVehicle(player: PlayerRef, name: TruckName | (string & {}) | null, kind?: "truck" | "car" | "bus"): void

Vehicle the player gets when pressing "Drive" without one of his own, instead of the game's "no vehicle" message. Defaults to fallback_vehicle in server.cfg. name like players.setVehicle; null = the game's message. kind: "truck" (default), "car" or "bus" (ETS2 1.61 has no drivable cars).

sendCompanyMessage

mp.players.sendCompanyMessage(player: PlayerRef, text: string): void

Shows a message in the player's company message line (HUD, next to the navigation). Messages queue up and scroll through one after another (the game keeps up to 16). Plain text, at most 200 characters.

clearCompanyMessages

mp.players.clearCompanyMessages(player: PlayerRef): void

Removes the shown company message and all waiting ones.

setCompany

mp.players.setCompany(player: PlayerRef, company: Company | null): void

Puts the player into a company of your gamemode, or out of every company with null (the game then shows no company). The game shows the company's name and logo as the player's own company in the top bar, and its Company menu category (with the mail) from the next desktop visit on. Memory only - nothing of the player's single-player company is changed on disk.

Types: Company

setFuel

mp.players.setFuel(player: PlayerRef, share: number): void

Fills the truck's tank to a share of its size: 1 = full, 0.25 = a quarter.

setFatigue

mp.players.setFatigue(player: PlayerRef, minutes: number): void

How long the driver has been driving without rest, in game minutes: 0 = fully rested (as after sleeping). Only matters with the fatigue rule on.

repairCargo

mp.players.repairCargo(player: PlayerRef): void

Repairs only the cargo of all the player's trailers (truck and trailer damage stay). players.repair repairs everything.

giveCargo

mp.players.giveCargo(player: PlayerRef, cargo: string, units?: number): void

Gives the player a trailer loaded with this cargo (a cargo id of mp.world.cargo(), e.g. "apples") - without a job. units: number of units, leave out for the game's default.

fine

mp.players.fine(player: PlayerRef, offence: Offence, amount?: number): void

Lets the game's police fine the player for an offence (the names of playerFined, e.g. "speeding") - at once, with the game's message, also without a police car around and with the "fines" rule off. amount in euro; leave out for the game's own amount. playerFined fires as for any fine.

teleportToJob

mp.players.teleportToJob(player: PlayerRef, withTime?: boolean): void

Moves the player to where their job continues: the trailer at the source, or the destination once loaded. With withTime the game time moves on as if they had driven (fuel, driving time); without, it is an instant jump.

teleportToCompany

mp.players.teleportToCompany(player: PlayerRef, company: string, city: string): void

Moves the player's truck to a company's depot (ids as in mp.world.companies(), e.g. "tradeaux", "dusseldorf"), facing into the yard. Throws if the depot is unknown or has no spawn point.

teleportToCity

mp.players.teleportToCity(player: PlayerRef, city: string): void

Moves the player's truck into a city: to one of its depots (mp.world data needed). Throws if the city has no depot with a spawn point.

setGhost

mp.players.setGhost(player: PlayerRef, on: boolean): void

Ghost mode: the player drives through everyone and everyone through them - like in a safe zone, but everywhere. Their HUD shows "Ghost mode".

setVisible

mp.players.setVisible(player: PlayerRef, visible: boolean): void

false hides the player from everyone else: no truck, no name, not in the list - for admins watching or separate events. They see the others as before.

sendMail

mp.players.sendMail(player: PlayerRef, mail: Mail): void

Puts a mail into the player's mail screen in the game (desktop menu Mail), with the game's "new mail" mark - for welcome letters, rules, rewards. Needs subject or body. Mails live until the player leaves the server. The game's own mails (bank, dealers, ...) never arrive, and every player starts with an empty mail screen.

Types: Mail

kick

mp.players.kick(player: PlayerRef, reason?: string): void

Kicks the player from the server.

all

mp.players.all(): readonly Player[]

All connected players.

Types: Player

get

mp.players.get(id: number): Player | undefined

The player with this id, or undefined.

Types: Player

On this page