GetVehicleDoorState: Difference between revisions
Jump to navigation
Jump to search
(→Syntax) |
(→Syntax) |
||
(14 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server client function}} | {{Server client function}} | ||
This function returns the current state of | This function returns the current state of the specifed door on the vehicle. | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> int getVehicleDoorState ( vehicle, door )</syntaxhighlight> | <syntaxhighlight lang="lua">int getVehicleDoorState ( vehicle theVehicle, int door )</syntaxhighlight> | ||
{{OOP||[[vehicle]]:getDoorState||setVehicleDoorState}} | |||
==Required Arguments== | ==Required Arguments== | ||
*''' | *'''theVehicle:''' the vehicle you want to get the door status of. | ||
*''' | *'''door:''' a whole number representing which door to get the status of. Valid values are: | ||
** '''0:''' Hood | |||
** '''1:''' Trunk | |||
** '''2:''' Front left | |||
** '''3:''' Front right | |||
** '''4:''' Rear left | |||
** '''5:''' Rear right | |||
==Returns== | |||
If successful, one of the following integers will be returned: | |||
* '''0:''' Shut, intact (also returned if the door does not exist) | |||
* '''1:''' Ajar, intact | |||
* '''2:''' Shut, damaged | |||
* '''3:''' Ajar, damaged | |||
* '''4:''' Missing | |||
==Example== | ==Example== | ||
<syntaxhighlight lang="lua">local | This example implements a doesVehicleHaveDoorOpen() function, that returns true if any of the doors on a vehicle are open. | ||
local | <syntaxhighlight lang="lua">function doesVehicleHaveDoorOpen(vehicle) | ||
local isDoorAjar = false | |||
for i=0,5 do | |||
local doorState = getVehicleDoorState(vehicle, i) | |||
if doorState == 1 or doorState == 3 or doorState == 4 then | |||
isDoorAjar = true | |||
end | |||
end | |||
return isDoorAjar | |||
end</syntaxhighlight> | |||
==See Also== | ==See Also== | ||
{{Vehicle functions}} | {{Vehicle functions}} |
Latest revision as of 19:47, 14 July 2017
This function returns the current state of the specifed door on the vehicle.
Syntax
int getVehicleDoorState ( vehicle theVehicle, int door )
OOP Syntax Help! I don't understand this!
- Method: vehicle:getDoorState(...)
- Counterpart: setVehicleDoorState
Required Arguments
- theVehicle: the vehicle you want to get the door status of.
- door: a whole number representing which door to get the status of. Valid values are:
- 0: Hood
- 1: Trunk
- 2: Front left
- 3: Front right
- 4: Rear left
- 5: Rear right
Returns
If successful, one of the following integers will be returned:
- 0: Shut, intact (also returned if the door does not exist)
- 1: Ajar, intact
- 2: Shut, damaged
- 3: Ajar, damaged
- 4: Missing
Example
This example implements a doesVehicleHaveDoorOpen() function, that returns true if any of the doors on a vehicle are open.
function doesVehicleHaveDoorOpen(vehicle) local isDoorAjar = false for i=0,5 do local doorState = getVehicleDoorState(vehicle, i) if doorState == 1 or doorState == 3 or doorState == 4 then isDoorAjar = true end end return isDoorAjar end
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