Open Road MP

Game rules

Police, traffic, fatigue, fuel and more - the same for every player.

Game rules are settings of ETS2 that the server sets for all players: police patrols, traffic density, fatigue, fuel consumption, bad weather, income factor and more. Players see the most important ones in the server list before they connect.

All rules with type, range and default: API reference → Game rules.

Players cannot change these settings themselves: the matching entries in the game's options (speed limiter, advanced trailer coupling, fuel and fatigue simulation, rain probability, road events, police ...) are hidden on a server.

Reading and changing

const rules = mp.rules.get()
if (rules.police) mp.log("police is on")

mp.rules.set("traffic", 0.3)   // less traffic
mp.rules.set("police", false)  // no police

A change applies at once to every player on the server - also to those who join later. Numbers outside a rule's range throw an error.

// Night mode: less traffic between 22:00 and 6:00 server time
setInterval(() => {
  const hour = new Date().getHours()
  mp.rules.set("traffic", hour >= 22 || hour < 6 ? 0.3 : 1)
}, 60 * 1000)

Fines

With fines off, the game charges nothing for offences. playerFined still fires (with amount 0), so your gamemode can decide what an offence costs:

mp.rules.set("fines", false)

mp.events.on("playerFined", (player, fine) => {
  if (fine.offence === "speeding_camera") {
    const money = 500
    mp.chat.send(player, `Speed camera: ${money} € - deducted by the server.`)
    // keep your own account per player and use mp.players.setMoney(...)
  }
})

Other ways to set rules

  • Start values in server.cfg: rule_police = false, rule_traffic = 0.5
  • Server console while running: rule police off

All three change the same rules - a gamemode sees changes from the console in mp.rules.get().

On this page