Skip to content

Occupants and seats

On the server, players and NPC peds expose setIntoVehicle() and removeFromVehicle(). Normal player entry and exit are synchronized automatically.

Seat Meaning
-1 Driver. This is the default when the seat argument is omitted.
0 First passenger seat.
1 through 14 Additional passenger seats, where the vehicle model provides them.

The API accepts seat indices from -1 to 14. A model can have fewer seats. Clients check the actual model and reject assignments to seats it does not have.

Call this server function with an already spawned player. It creates a vehicle at the player’s position, matches their dimension and assigns the driver seat:

Server
// @ts-check
/// <reference types="@revomp/types-server" />
import * as revo from 'revo-server';
/** @param {revo.Player} player An already spawned player. */
export function createVehicleForPlayer(player) {
const vehicle = new revo.Vehicle('sultan', player.pos);
vehicle.dimension = player.dimension;
if (!player.setIntoVehicle(vehicle, -1)) {
vehicle.destroy();
return null;
}
return vehicle;
}

You can call setIntoVehicle() immediately after creating the vehicle. Revo retains the assignment while the client receives the vehicle and loads its model. The client applies placement when both the ped and vehicle are ready.

Placement moves the ped into the seat without an entry animation. It can also transfer the ped to another vehicle or seat, releasing the previous seat. Requesting the same occupied seat for the same ped returns true without a change.

The same method works on a server-created Ped, for example ped.setIntoVehicle(vehicle, 0).

setIntoVehicle() returns false when:

  • The requested seat is occupied or reserved by another ped or player.
  • The ped is dead, or the player has not spawned.
  • The seat index is outside the supported range.
  • The vehicle is outside the ped’s visible dimension.

A vehicle in globalDimension is visible from any numbered dimension. For other vehicles, match the dimensions before placement. Revo can move the ped to a distant vehicle and bring it into streaming range.

Wrong argument types, fractional seat indices and destroyed objects throw an error. Handle a rejected assignment separately from invalid API arguments.

ped.vehicleOccupancy returns a snapshot with phase, vehicle and seat. Read the property again when you need updated state.

VehicleOccupancyPhase Meaning
OnFoot No vehicle assignment. vehicle is null.
Entering Entry is in progress.
Seated The server has assigned the ped to the seat.
Exiting Exit is in progress.

Check phase when your logic requires a seated occupant. During entry or exit, the state still references the vehicle. The seat value is only meaningful while there is a vehicle assignment.

vehicle.getSeatOccupant(seat) returns a Player or Ped object, or null if the seat is empty. A reservation during entry can also fill the seat slot, so check the occupant’s phase when your logic requires a seated ped.

Server
// @ts-check
/// <reference types="@revomp/types-server" />
import * as revo from 'revo-server';
/** @param {revo.Ped} ped A player or server-created NPC. */
export function getSeatedVehicle(ped) {
const state = ped.vehicleOccupancy;
return state.phase === revo.VehicleOccupancyPhase.Seated
? state.vehicle
: null;
}
/** @param {revo.Vehicle} vehicle */
export function getDriver(vehicle) {
return vehicle.getSeatOccupant(-1);
}

Client scripts can also read vehicleOccupancy on networked peds and players, including Player.local. It is null for a LocalPed or when network state is unavailable. Its vehicle can be null while the referenced vehicle is unavailable on that client. Check readiness before using a GTA handle.

Call ped.removeFromVehicle() or player.removeFromVehicle() on the server. It releases the server seat immediately and instructs clients to remove the ped. GTA chooses the exit position.

This also cancels pending entry or exit. Calling it while on foot is supported and cancels an entry request still in transit. There is no need to check for Seated before using it to cancel vehicle interaction.

These server events receive (player, vehicle, seat). The two marked below also receive reason as the fourth argument.

Event When it is reported
playerEnteringVehicle The server accepts an entry transition.
playerEnteredVehicle Occupancy changes to Seated.
playerExitingVehicle The server accepts an exit transition.
playerExitedVehicle A seated or exiting player is released to OnFoot. Includes reason.
playerVehicleEntryCancelled Entry ends before reaching Seated. Includes reason.

Scripted placement and removal can skip Entering and Exiting. In particular, playerEnteredVehicle after setIntoVehicle() can run before the client finishes loading the vehicle. It reports server state. Use the client’s readiness events when work depends on a loaded vehicle.

Reasons come from VehicleExitReason: Normal, Cancelled, Timeout, Teleport, Respawn, VehicleRemoved, Disconnected and Invalidated. Scripted removal uses Teleport.

These events cover players. Read vehicleOccupancy for NPCs. They are queued state notifications, and returning false does not cancel the transition. Check that referenced entities remain valid before accessing their properties.

Revo releases assignments when an occupant dies or disconnects, a player respawns, or the vehicle is removed. Teleporting a ped can also release its seat. For occupied vehicles moving between dimensions, follow the dimension rules.