M MY Multiplayer: Wiki
Side
Kind

getVehicleOccupants

Shared

Returns every ped and player inside a vehicle.

table|false getVehicleOccupants(vehicle vehicle)

Parameters

NameTypeDescription
vehiclevehicleThe 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

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)
NoteThe driver is at key 0, which ipairs and # do not see. Walk the table with pairs.

See also