Skip to content

Vehicles ​

Create networked vehicles on the server. The manager returns null when the max_vehicles capacity is exhausted.

ts
vimp.on('playerConnected', (player) => {
  const vehicle = vimp.vehicles.create(
    vimp.hash('adder'),
    94.5,
    -1940.2,
    20.7,
    307,
    {
      primaryColor: 27,
      secondaryColor: 111,
      numberPlate: 'VIMP',
      lockState: 1,
      engineOn: true,
      dimension: player.dimension,
    },
  )

  if (vehicle) {
    vehicle.setStreamSyncedMeta('ownerId', player.id)
    player.putIntoVehicle(vehicle.id, -1)
  }
})

Writable properties such as position, rotation, paint, plate, dirt, livery, lock state, health, engine state, and dimension update authoritative state and are forwarded to clients that stream the vehicle.

Ownership ​

VIMP does not impose a gameplay ownership model. Store a compact owner key in stream-synced metadata for presentation, and keep the authoritative record in server application state or a database.

Validate custom requests before changing a vehicle:

  • the sender owns or may use it;
  • the vehicle still exists;
  • the sender is close enough and in the same dimension;
  • the requested value is allowed by the gamemode.

Client wrappers ​

Client vehicles expose a local id, a nullable remoteId, and a GTA handle. Use remoteId for generic entity metadata and handle for natives. A remote wrapper can exist with handle === 0 outside the current streaming range.

Destroy vehicles explicitly when a session, job, or temporary instance ends. Holding a JavaScript reference does not keep a destroyed entity alive.

VIMP developer documentation