- Documentation
- Shared functions
- getVehicleOccupants
Function
getVehicleOccupants
Returns everyone (players and peds) sitting in the vehicle as a table of seat number → occupant. Empty seats are not in the table, so loop over it with pairs, not ipairs (seat 0 is not an array index).
Syntax
table getVehicleOccupants(vehicle vehicle)Arguments
vehiclevehicle- The vehicle.
Returns
A table { [seat] = player/ped }.
Example
local function vehicleMessage(vehicle, text)
for seat, occupant in pairs(getVehicleOccupants(vehicle)) do
if getElementType(occupant) == "player" then outputChatBox(text, occupant) end
end
end
See also
getVehicleOccupantReturns the player or ped sitting in the given seat of a vehicle. Seat 0 is the driver, 1 the front passenger, 2 and 3 the rear seats.getVehicleMaxPassengersReturns the number of passenger seats of a vehicle or model (not counting the driver): e.g. 1 for a two-seater, 3 for a saloon. The data comes from the game, so the server only knows it once a client reports it (usually after the model first appears for a player); before that it returnsfalse.