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

Function

getPedOccupiedVehicle

Server and clientPedsIdentical to MTA:SA

Returns the vehicle a ped is sitting in (as the driver or a passenger). When the ped is on foot it returns false. It is the simplest way to find out what a player is driving, e.g. to repair or recolour their car.

Syntax

vehicle getPedOccupiedVehicle(ped ped)

Arguments

pedped
A player or an NPC.

Returns

The vehicle, or false when the ped is on foot.

Example

addCommandHandler("napraw", function(player)
    local car = getPedOccupiedVehicle(player)
    if car then fixVehicle(car) end
end)

See also