# getVehicleOccupant (Shared)

> Returns the ped or player sitting in a seat of a vehicle.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Shared
- **Category**: Vehicles
- **URL**: https://wiki.mymp.gg/en/getVehicleOccupant

## Syntax

```lua
ped|false getVehicleOccupant(vehicle vehicle [, int seat = 0])
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `vehicle` | `vehicle` | The vehicle. |
| `seat` | `int` | The seat: 0 is the driver, 1 and up the passengers (up to 15). *(default: `0`)* |

## Returns

The ped or player in the seat, or `false` if the seat is empty or does not exist, or the element is not a vehicle.

## Example

```lua
addEventHandler("onVehicleEnter", root, function(ped, seat)
    local driver = getVehicleOccupant(source, 0)
    if driver and seat ~= 0 then
        outputDebugString("a passenger got in")
    end
end)
```

## See also

- [getVehicleOccupants (Shared)](https://wiki.mymp.gg/en/getVehicleOccupants.md): Returns every ped and player inside a vehicle.
- [getVehicleController (Shared)](https://wiki.mymp.gg/en/getVehicleController.md): Returns who is driving a vehicle, that is the occupant of seat 0.
- [getPedOccupiedVehicle (Shared)](https://wiki.mymp.gg/en/getPedOccupiedVehicle.md): Gets the vehicle a ped or player is in.
- [warpPedIntoVehicle (Shared)](https://wiki.mymp.gg/en/warpPedIntoVehicle.md): Puts a ped or player straight into a vehicle seat, with no animation.
