# getVehicleOccupants (Shared)

> Returns every ped and player inside a vehicle.

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

## Syntax

```lua
table|false getVehicleOccupants(vehicle vehicle)
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `vehicle` | `vehicle` | The vehicle. |

## Returns

A table of seat → ped or player, with the driver in seat 0; or `false` if the element is not a vehicle.

## Example

```lua
addCommandHandler("ocupantes", function(player)
    local vehicle = getPedOccupiedVehicle(player)
    if not vehicle then return end
    for seat, occupant in pairs(getVehicleOccupants(vehicle)) do
        outputDebugString("seat " .. seat .. " is taken")
    end
end)
```

### Note

The driver is at key `0`, which `ipairs` and `#` do not see. Walk the table with `pairs`.

## See also

- [getVehicleOccupant (Shared)](https://wiki.mymp.gg/en/getVehicleOccupant.md): Returns the ped or player sitting in a seat of a vehicle.
- [getVehicleController (Shared)](https://wiki.mymp.gg/en/getVehicleController.md): Returns who is driving a vehicle, that is the occupant of seat 0.
- [getVehicleMaxPassengers (Server)](https://wiki.mymp.gg/en/getVehicleMaxPassengers-server.md): Tells how many passengers fit in a vehicle, not counting the driver.
