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.
Signature
Section titled “Signature”server.on("playerEnterVehicleRequest", ({ player, vehicleId, seat, hasNpcDriver }) => boolean | void | Promise<boolean | void>)Parameters
Section titled “Parameters”| 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. |
Returns
Section titled “Returns”false keeps the player out. Anything else lets them in. The first false stops the handlers after it. See how decisions work.
Example
Section titled “Example”No carjacking.
import { chat, server } from "nativemp";
server.on("playerEnterVehicleRequest", ({ player, hasNpcDriver }) => { if (!hasNpcDriver) return true; chat.sendServerMessage("No carjacking on this server.", player); return false;});Related
Section titled “Related”playerEnteredVehicle: the player got inplayers.putInVehicle: seat a player yourself