GetVehicleOccupant: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
(7 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | |||
{{Server client function}} | |||
This function gets the player sitting/trying to enter the specified vehicle. | |||
This function gets the player sitting | |||
==Syntax== | ==Syntax== | ||
Line 8: | Line 7: | ||
player getVehicleOccupant ( vehicle theVehicle, [ int seat=0 ] ) | player getVehicleOccupant ( vehicle theVehicle, [ int seat=0 ] ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[vehicle]]:getOccupant}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
*'''theVehicle:''' | *'''theVehicle:''' the [[vehicle]] of which you wish to retrieve the driver or a passenger. | ||
===Optional Arguments=== | ===Optional Arguments=== | ||
{{OptionalArg}} | {{OptionalArg}} | ||
*'''seat:''' | *'''seat:''' the seat where the player is sitting (0 for driver, 1+ for passengers). | ||
===Returns=== | ===Returns=== | ||
Line 22: | Line 21: | ||
This example announces the driver of a certain vehicle whenever it is damaged: | This example announces the driver of a certain vehicle whenever it is damaged: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function onStolenVehicleDamage ( loss ) | function onStolenVehicleDamage ( loss ) | ||
local driver = getVehicleOccupant ( source ) -- get the player sitting in seat 0 | |||
if ( driver ) then -- if the driver exists, display a message | |||
outputChatBox ( getPlayerName ( driver ) .. " is wrecking the vehicle he stole!" ) | |||
end | |||
end | end | ||
addEventHandler ( "onVehicleDamage", stolenVehicle, onStolenVehicleDamage ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{ | {{Vehicle_functions}} |
Latest revision as of 21:58, 27 June 2020
This function gets the player sitting/trying to enter the specified vehicle.
Syntax
player getVehicleOccupant ( vehicle theVehicle, [ int seat=0 ] )
OOP Syntax Help! I don't understand this!
- Method: vehicle:getOccupant(...)
Required Arguments
- theVehicle: the vehicle of which you wish to retrieve the driver or a passenger.
Optional Arguments
NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.
- seat: the seat where the player is sitting (0 for driver, 1+ for passengers).
Returns
Returns the player sitting in the vehicle, or false if the seat is unoccupied or doesn't exist.
Example
This example announces the driver of a certain vehicle whenever it is damaged:
function onStolenVehicleDamage ( loss ) local driver = getVehicleOccupant ( source ) -- get the player sitting in seat 0 if ( driver ) then -- if the driver exists, display a message outputChatBox ( getPlayerName ( driver ) .. " is wrecking the vehicle he stole!" ) end end addEventHandler ( "onVehicleDamage", stolenVehicle, onStolenVehicleDamage )
See Also
- addVehicleUpgrade
- attachTrailerToVehicle
- blowVehicle
- createVehicle
- detachTrailerFromVehicle
- fixVehicle
- getOriginalHandling
- getTrainDirection
- getTrainPosition
- getTrainSpeed
- getTrainTrack
- getVehicleColor
- getVehicleCompatibleUpgrades
- getVehicleController
- getVehicleDoorOpenRatio
- getVehicleDoorState
- getVehicleEngineState
- getVehicleHandling
- getVehicleHeadLightColor
- getVehicleLandingGearDown
- getVehicleLightState
- getVehicleMaxPassengers
- getVehicleModelFromName
- getVehicleName
- getVehicleNameFromModel
- getVehicleOccupant
- getVehicleOccupants
- getVehicleOverrideLights
- getVehiclePaintjob
- getVehiclePanelState
- getVehiclePlateText
- getVehicleSirenParams
- getVehicleSirens
- getVehicleSirensOn
- getVehicleTowedByVehicle
- getVehicleTowingVehicle
- getVehicleTurretPosition
- getVehicleType
- getVehicleUpgradeOnSlot
- getVehicleUpgradeSlotName
- getVehicleUpgrades
- getVehicleVariant
- getVehicleWheelStates
- isTrainDerailable
- isTrainDerailed
- isVehicleBlown
- isVehicleDamageProof
- isVehicleFuelTankExplodable
- isVehicleLocked
- isVehicleOnGround
- isVehicleTaxiLightOn
- removeVehicleUpgrade
- setTrainDerailable
- setTrainDerailed
- setTrainDirection
- setTrainPosition
- setTrainSpeed
- setTrainTrack
- setVehicleColor
- setVehicleDamageProof
- setVehicleDoorOpenRatio
- setVehicleDoorState
- setVehicleDoorsUndamageable
- setVehicleEngineState
- setVehicleFuelTankExplodable
- setVehicleHandling
- setVehicleHeadLightColor
- setVehicleLandingGearDown
- setVehicleLightState
- setVehicleLocked
- setVehicleOverrideLights
- setVehiclePaintjob
- setVehiclePanelState
- setVehiclePlateText
- setVehicleSirens
- setVehicleSirensOn
- setVehicleTaxiLightOn
- setVehicleTurretPosition
- setVehicleVariant
- setVehicleWheelStates