Ped::isInVehicle
Description
This function checks if a specified pedestrian (ped) is currently inside a given vehicle. It can also check if the ped is in the process of entering the vehicle, depending on the value of atGetIn. This function is helpful for determining when a character is in or near entering a specific vehicle, allowing for additional gameplay logic to be applied.
Required Params
- ped: number - The pedestrian handle to check.
- vehicle: number - The vehicle handle to check against.
- atGetIn: boolean - Set
trueto include checking if the ped is getting into the vehicle; otherwise, only checks if the ped is fully inside.
Return value
- boolean - Returns
trueif the ped is in the vehicle (or entering it ifatGetInistrue); otherwise,false.
Syntax
mp.game.ped.isInVehicle(ped, vehicle, atGetIn)
Example
// Check if a pedestrian is in or entering a specific vehicle
const ped = mp.players.local.handle;
const vehicle = mp.vehicles.at(0).handle;
if (mp.game.ped.isInVehicle(ped, vehicle, true)) {
mp.gui.chat.push("Pedestrian is in or entering the vehicle.");
} else {
mp.gui.chat.push("Pedestrian is not in the vehicle.");
}