Skip to content

Trailers and towing

Trailers, tow-truck attachments and tow-arm movement are synchronized.

Create both vehicles on the server. This example places a Phantom and a trailer near the beach and logs attachment and detachment events:

Server
// @ts-check
/// <reference types="@revomp/types-server" />
import * as revo from 'revo-server';
const truck = new revo.Vehicle(
'phantom',
{ x: -1240, y: -1795, z: 3.9 },
0,
);
const trailer = new revo.Vehicle(
'trailers2',
{ x: -1229, y: -1787, z: 3.9 },
0,
);
truck.numberPlate = 'HAULER';
trailer.numberPlate = 'CARGO';
revo.on('trailerAttached', (towing, attached) => {
if (!towing.valid || !attached.valid) return;
revo.log(`Vehicle ${towing.id} attached vehicle ${attached.id}.`);
});
revo.on('trailerDetached', (towing, attached) => {
if (!towing.valid || !attached.valid) return;
revo.log(`Vehicle ${towing.id} released vehicle ${attached.id}.`);
});

Enter the Phantom and reverse toward the trailer’s hitch to couple them. Use GTA’s vehicle controls to disconnect. For a tow truck, position its hook at an empty vehicle and use its towing controls to pick up or release it.

Trailer and tow-truck couplings use GTA’s vehicle controls. Accepted connections are recorded on the server.

A shared attachment requires:

  • Two server-created vehicles using a compatible trailer hitch or tow arm.
  • A player seated in the towing vehicle’s driver seat.
  • An empty target vehicle, with no occupied or reserved seats.
  • Both vehicles in the same dimension.
  • Both vehicles loaded on the driver’s client, with the towing vehicle simulated by that client.

Each vehicle can belong to one towing pair. Multiple-trailer chains are not supported. A target already connected to another vehicle must be released first.

The dimensions must match exactly. A vehicle in globalDimension can be visible alongside a vehicle in dimension 0, but the two cannot form a towing pair.

These properties are read-only and available on the server:

Property Value
vehicle.trailer The vehicle it is towing, or null. This includes a car attached to a tow truck.
vehicle.parent The vehicle towing it, or null.

For a connected pair, truck.trailer === trailer and trailer.parent === truck. Use these properties when you need the current connection, such as checking which vehicle a player has brought to a delivery point.

Client Vehicle objects do not expose these properties. If a client interface needs them, send the relevant server state using a script message or synced metadata.

The server emits trailerAttached(truck, trailer) and trailerDetached(truck, trailer). These events also cover tow-truck pickups. The second argument is the attached vehicle, even when it is an ordinary car.

These are queued notifications after the connection changes. They cannot cancel an attachment by returning a value. Check valid before accessing either vehicle’s properties because one may have been destroyed before the callback runs. The current connection may also have changed by then.

The two vehicles share a simulation owner while attached. The towing vehicle’s driver takes priority. Revo retains the connection when ownership transfers, including when another eligible client takes over after a disconnect. See Ownership and simulation.

Observers receive the connection with the vehicle state. They can restore the coupling once both vehicles are loaded. Streaming a vehicle out removes its local GTA instance while the server connection remains available for its next stream-in. No script is needed to reattach it on each observing client.

Assigning the server position or rotation of either member also moves the connected vehicle, preserving their relative placement. Apply a teleport to one member of the pair. Assigning both positions separately moves the pair twice.

Changing either vehicle’s dimension moves both vehicles. Occupants follow a move to a numbered dimension. When the vehicles become global, occupants keep their current dimensions. See Vehicles and occupants.

Destroying either vehicle clears the connection and leaves the other vehicle in the world. Destroy both explicitly if your cleanup should remove the whole pair. Changing either vehicle’s model also detaches the pair.

To attach props or use bones as attachment points, call entity.attachTo() on the server. See Moving entities and attaching props for bone, ownBone, offsets and rotation.

Local-only vehicle pairs follow GTA’s native behavior and remain local. A shared towing pair cannot combine a server vehicle with a LocalVehicle.