ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Shared functions
  3. getVehicleOccupant

Function

getVehicleOccupant

Server and clientVehiclesIdentical to MTA:SA

Returns 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.

Syntax

player getVehicleOccupant(vehicle vehicle [, int seat = 0])

Arguments

vehiclevehicle
The vehicle.
seatint, optional = 0
Seat number.

Returns

The player or ped in the seat, or false when it is empty.

Example

addCommandHandler("kierowca", function(player)
    local vehicle = getPedOccupiedVehicle(player)
    local driver = vehicle and getVehicleOccupant(vehicle, 0)
    if driver and getElementType(driver) == "player" then
        outputChatBox("Kierowca: " .. getPlayerName(driver), player)
    end
end)

See also