Skip to content

Commit

Permalink
Update GetVehiclePedIsIn.md
Browse files Browse the repository at this point in the history
  • Loading branch information
spacevx committed Dec 18, 2023
1 parent 865ffea commit 6b75ae8
Showing 1 changed file with 52 additions and 3 deletions.
55 changes: 52 additions & 3 deletions PED/GetVehiclePedIsIn.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,61 @@ ns: PED
Vehicle GET_VEHICLE_PED_IS_IN(Ped ped, BOOL lastVehicle);
```
Gets the vehicle the specified Ped is in. Returns 0 if the ped is/was not in a vehicle.
If the Ped is not in a vehicle and includeLastVehicle is true, the vehicle they were last in is returned.
Retrieves the vehicle the specified ped is currently in, or the last vehicle they were in.
## Parameters
* **ped**: The target ped
* **lastVehicle**: False = CurrentVehicle, True = LastVehicle
* **lastVehicle**: A boolean value where `false` represents the current vehicle the Ped is in, and `true` represents the last vehicle the Ped was in.
## Return value
The vehicle id. Returns 0 if the ped is/was not in a vehicle.
## Examples
```lua
-- This example gets the vehicle the player is currently in
-- Retrieve the player ped
local playerPed = PlayerPedId()
-- Retrieve the vehicle the player is currently in
local vehicle = GetVehiclePedIsIn(playerPed, false)
-- Check if the vehicle exists. If not, terminate the script.
if not DoesEntityExist(vehicle) then return end
-- Do whatever you want with the vehicle, for example here we are setting the vehicle's engine health to 1000
SetVehicleEngineHealth(vehicle, 1000.0)
```

```js
// This example gets the vehicle the player is currently in

// Retrieve the player ped
const playerPed = PlayerPedId();

// Retrieve the vehicle the player is currently in
const vehicle = GetVehiclePedIsIn(playerPed, false);

// Check if the vehicle exists. If not, terminate the script.
if (!DoesEntityExist(vehicle)) return;

// Do whatever you want with the vehicle, for example here we are setting the vehicle's engine health to 1000
SetVehicleEngineHealth(vehicle, 1000.0);
```

```cs
// This example gets the vehicle the player is currently in
using static CitizenFX.Core.Native.API;

// Retrieve the player ped
Ped playerPed = PlayerPedId();

// Retrieve the vehicle the player is currently in
Vehicle vehicle = GetVehiclePedIsIn(playerPed, false);

// Check if the vehicle exists. If not, terminate the script.
if (!DoesEntityExist(vehicle)) return;

// Do whatever you want with the vehicle, for example here we are setting the vehicle's engine health to 1000
SetVehicleEngineHealth(vehicle, 1000.0);
```

0 comments on commit 6b75ae8

Please sign in to comment.