GetPedOccupiedVehicle: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
(6 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server client function}} | {{Server client function}} | ||
This function gets the [[vehicle]] that the ped is currently in, if any. | This function gets the [[vehicle]] that the ped is currently in or is trying to enter, if any. | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua">vehicle getPedOccupiedVehicle ( ped thePed )</syntaxhighlight> | <syntaxhighlight lang="lua">vehicle getPedOccupiedVehicle ( ped thePed )</syntaxhighlight> | ||
{{OOP|Set the variable to nil to execute [[removePedFromVehicle]]|[[ped]]:getOccupiedVehicle|vehicle|warpPedIntoVehicle}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
Line 15: | Line 16: | ||
When a ped enters the 'getcarname' command and is currently in a vehicle, this example outputs the name of the vehicle. | When a ped enters the 'getcarname' command and is currently in a vehicle, this example outputs the name of the vehicle. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function showVehicleName ( | function showVehicleName ( thePlayer ) | ||
local theVehicle = getPedOccupiedVehicle ( | local theVehicle = getPedOccupiedVehicle ( thePlayer ) | ||
if theVehicle then | if theVehicle then | ||
outputChatBox ( "Name of the Vehicle: " .. getVehicleName ( theVehicle ), | outputChatBox ( "Name of the Vehicle: " .. getVehicleName ( theVehicle ), thePlayer ) | ||
else | else | ||
outputChatBox ( "You do not have a Vehicle!", | outputChatBox ( "You do not have a Vehicle!", thePlayer, 255, 0, 0, true ) | ||
end | end | ||
end | end | ||
Line 28: | Line 29: | ||
==See Also== | ==See Also== | ||
{{Client_ped_functions}} | {{Client_ped_functions}} | ||
[[hu:getPedOccupiedVehicle]] |
Latest revision as of 17:54, 7 October 2018
This function gets the vehicle that the ped is currently in or is trying to enter, if any.
Syntax
vehicle getPedOccupiedVehicle ( ped thePed )
OOP Syntax Help! I don't understand this!
- Note: Set the variable to nil to execute removePedFromVehicle
- Method: ped:getOccupiedVehicle(...)
- Variable: .vehicle
- Counterpart: warpPedIntoVehicle
Required Arguments
- thePed: The ped whose vehicle you're looking up.
Returns
Returns the vehicle that the specified ped is in, or false if the ped is not in a vehicle or is an invalid ped.
Example
When a ped enters the 'getcarname' command and is currently in a vehicle, this example outputs the name of the vehicle.
function showVehicleName ( thePlayer ) local theVehicle = getPedOccupiedVehicle ( thePlayer ) if theVehicle then outputChatBox ( "Name of the Vehicle: " .. getVehicleName ( theVehicle ), thePlayer ) else outputChatBox ( "You do not have a Vehicle!", thePlayer, 255, 0, 0, true ) end end addCommandHandler ( "getcarname", showVehicleName )
See Also
- canPedBeKnockedOffBike
- getPedAnalogControlState
- getPedAnimation
- getPedBonePosition
- getPedCameraRotation
- getPedControlState
- getPedMoveState
- getPedOxygenLevel
- getPedSimplestTask
- getPedTargetCollision
- getPedTargetEnd
- getPedTargetStart
- getPedTask
- getPedVoice
- getPedWeaponMuzzlePosition
- givePedWeapon
- isPedBleeding
- isPedDoingTask
- isPedReloadingWeapon
- isPedTargetingMarkerEnabled
- setAnalogControlState
- setPedAimTarget
- setPedAnalogControlState
- setPedBleeding
- setPedCameraRotation
- setPedCanBeKnockedOffBike
- setPedControlState
- setPedEnterVehicle
- setPedExitVehicle
- IsPedFootBloodEnabled
- setPedFootBloodEnabled
- setPedLookAt
- setPedOxygenLevel
- setPedTargetingMarkerEnabled
- setPedVoice
- Shared
- addPedClothes
- getPedClothes
- removePedClothes
- createPed
- getPedAmmoInClip
- getPedArmor
- getPedFightingStyle
- getPedOccupiedVehicle
- getPedOccupiedVehicleSeat
- getPedStat
- getPedTarget
- getPedTotalAmmo
- getPedWalkingStyle
- getPedWeapon
- getPedWeaponSlot
- getPedContactElement
- getValidPedModels
- isPedChoking
- isPedDead
- isPedDoingGangDriveby
- isPedDucked
- isPedHeadless
- isPedInVehicle
- isPedOnFire
- isPedOnGround
- isPedWearingJetpack
- killPed
- removePedFromVehicle
- setPedAnimation
- setPedAnimationProgress
- setPedAnimationSpeed
- setPedArmor
- setPedDoingGangDriveby
- setPedFightingStyle
- setPedHeadless
- setPedOnFire
- setPedStat
- setPedWalkingStyle
- setPedWeaponSlot
- warpPedIntoVehicle