SetVehicleDoorState: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
|||
(13 intermediate revisions by 11 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server client function}} | {{Server client function}} | ||
This function sets the state of | This function sets the state of the specified door on a vehicle. | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua">setVehicleDoorState ( vehicle | <syntaxhighlight lang="lua">bool setVehicleDoorState ( vehicle theVehicle, int door, int state )</syntaxhighlight> | ||
{{OOP||[[vehicle]]:setDoorState||getVehicleDoorState}} | |||
{{New feature/item|9.0158|1.5.8|20319| | |||
<syntaxhighlight lang="lua">bool setVehicleDoorState ( vehicle theVehicle, int door, int state [, bool spawnFlyingComponent = true ] )</syntaxhighlight> | |||
}} | |||
==Required Arguments== | ==Required Arguments== | ||
*'''theVehicle:''' | *'''theVehicle:''' The [[vehicle]] that you wish to change the door state of. | ||
*'''door:''' | *'''door:''' An integer representing which door to set the state of. Valid values are: | ||
*'''state:''' | **'''0:''' Hood | ||
**'''1:''' Trunk | |||
**'''2:''' Front left | |||
**'''3:''' Front right | |||
**'''4:''' Rear left | |||
**'''5:''' Rear right | |||
*'''state:''' An integer representing the state to set the door to. Valid values are: | |||
**'''0:''' Shut, intact (aka Closed, undamaged) | |||
**'''1:''' Ajar, intact (aka Slightly open, undamaged) | |||
**'''2:''' Shut, damaged (aka Closed, damaged) | |||
**'''3:''' Ajar, damaged (aka Slightly open, damaged) | |||
**'''4:''' Missing | |||
===Optional Arguments=== | |||
{{OptionalArg}} | |||
{{New feature/item|9.0158|1.5.8|20319| | |||
{{Note|This parameter doesn't work during the vehicle creation. You need a [[SetTimer]] if you need to create the vehicle using this parameter.}} | |||
*'''spawnFlyingComponent:''' A boolean, if set to true, spawns flying doors etc. if you remove a component with <nowiki>state == 4</nowiki>. | |||
}} | |||
==Returns== | ==Returns== | ||
Returns ''true'' if | Returns ''true'' if the door state was successfully set, ''false'' otherwise. | ||
==Example== | ==Example== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
local newcar = createVehicle ( | -- create a new vehicle | ||
local newcar = createVehicle (420, 2472.5, -1688, 13.3) | |||
-- break its front left door off | |||
setVehicleDoorState (newcar, 2, 4) | |||
-- make its hood disapear | |||
setTimer (setVehicleDoorState, 100, 1, newcar, 0, 4, false) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Vehicle functions}} | {{Vehicle functions}} |
Latest revision as of 17:38, 4 October 2022
This function sets the state of the specified door on a vehicle.
Syntax
bool setVehicleDoorState ( vehicle theVehicle, int door, int state )
OOP Syntax Help! I don't understand this!
- Method: vehicle:setDoorState(...)
- Counterpart: getVehicleDoorState
Required Arguments
- theVehicle: The vehicle that you wish to change the door state of.
- door: An integer representing which door to set the state of. Valid values are:
- 0: Hood
- 1: Trunk
- 2: Front left
- 3: Front right
- 4: Rear left
- 5: Rear right
- state: An integer representing the state to set the door to. Valid values are:
- 0: Shut, intact (aka Closed, undamaged)
- 1: Ajar, intact (aka Slightly open, undamaged)
- 2: Shut, damaged (aka Closed, damaged)
- 3: Ajar, damaged (aka Slightly open, damaged)
- 4: Missing
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.
Returns
Returns true if the door state was successfully set, false otherwise.
Example
-- create a new vehicle local newcar = createVehicle (420, 2472.5, -1688, 13.3) -- break its front left door off setVehicleDoorState (newcar, 2, 4) -- make its hood disapear setTimer (setVehicleDoorState, 100, 1, newcar, 0, 4, false)
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