Skip to content

Vehicles, players and the world

Players and vehicles are entities, identified by an EntityId that the authority assigns. IPlayer, IVehicle and ILocalVehicle are live views: keep them, and they stay current until IsValid becomes false. Players and Vehicles give lookup by id, the full list, and joined/left or spawned/despawned events.

Vehicle access goes to the actual OMSI-compatible bus, not a simplified copy:

  • model path, repaint, timetable (HOF), fleet number and registration;
  • position, rotation, velocity and angular velocity;
  • the bus’s own numeric and string script-variable tables;
  • script variable writes, triggers, and notifications when a trigger fires.

Doors, lights, dashboard controls and the like are defined by each bus’s OMSI scripts; they are not engine components. Control them through the bus’s real variables and triggers. The SDK does not invent a competing door or light model.

if (Vehicles.Local is { IsSpawned: true } bus)
{
float? speed = bus.ScriptVariables.GetNumber("Velocity");
if (bus.HasTrigger("bus_doorfront0")) bus.FireTrigger("bus_doorfront0");
}

Variable and trigger names come from the bus’s own scripts, so they differ between buses. Writing variables and firing triggers needs the vehicle.control permission.

A client resource can spawn and despawn the local player’s bus with Vehicles.SpawnAsync and DespawnAsync (vehicle.spawn). This goes through the normal game spawn path and, in multiplayer, the server’s content checks. A server resource can despawn another player’s bus (vehicle.admin); it cannot create an OMSI bus inside another player’s game, so a server resource that wants a bus spawned asks that player’s client half to do it.

On the client, World.Map describes the loaded map: its global.cfg tiles, the tiles currently loaded, entry points, timetable bus stops and routes, and live counts of AI vehicles, walking pedestrians and passengers.

World.DriverDuty is the local bus’s actual selected timetable journey: line, tour, destination, next stop, progress and delay, or null in free roam. In multiplayer the same duty is visible on that bus’s IVehicle.DriverDuty on the server.

Time and weather belong to the authority. Clients read them; a server resource changes them with World.SetTime, SetTimeScale and SetWeather (world.control), and everyone receives WeatherChanged.