- Documentation
- Shared functions
- isPedInVehicle
Function
isPedInVehicle
Checks whether a ped is sitting in any vehicle (in any seat). It also returns false while the ped is still getting in, before it takes the seat. When you need the vehicle itself, use getPedOccupiedVehicle.
Syntax
bool isPedInVehicle(ped ped)Arguments
pedped- A player or an NPC.
Returns
true when the ped is in a vehicle.
Example
addCommandHandler("teleport", function(player)
if isPedInVehicle(player) then
outputChatBox("Najpierw wysiądź z pojazdu.", player)
return
end
setElementPosition(player, 2495, -1687, 13.5)
end)
See also
getPedOccupiedVehicleReturns the vehicle a ped is sitting in (as the driver or a passenger). When the ped is on foot it returnsfalse. It is the simplest way to find out what a player is driving, e.g. to repair or recolour their car.removePedFromVehicleInstantly takes a player or an NPC out of a vehicle and places them next to it, without the get-out animation. It firesonPlayerVehicleExitjust like a normal exit and blocks the player from getting back in for 3 seconds so the game does not put them back. Returnsfalsewhen the ped is not in a vehicle.