Skip to content

playerEnterVehicleRequest

Asks your gamemode when a player tries to get into a vehicle. A vehicle you locked with vehicles.setLocked keeps the player out without asking.

Coming from SA-MP or open.mp: this is OnPlayerEnterVehicle, which comes when a player starts to get in. playerEnteredVehicle comes once they sit in it, like OnPlayerStateChange.

Renamed in 0.28 from enterRequest; see renamed names.

server.on("playerEnterVehicleRequest", ({ player, vehicleId, seat, hasNpcDriver }) => boolean | void | Promise<boolean | void>)
Name Type Description
player PlayerSnapshot The player.
vehicleId number The vehicle.
seat number 0 for the driver’s seat, 1 to 3 passenger seats.
hasNpcDriver boolean true when an NPC is driving it: getting in means pulling them out.

false keeps the player out. Anything else lets them in. The first false stops the handlers after it. See how decisions work.

No carjacking.

gamemodes/my-mode.ts
import { chat, server } from "nativemp";
server.on("playerEnterVehicleRequest", ({ player, hasNpcDriver }) => {
if (!hasNpcDriver) return true;
chat.sendServerMessage("No carjacking on this server.", player);
return false;
});