SetVehicleDoorState: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Added sections, minor changes)
No edit summary
(8 intermediate revisions by 8 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Server client function}}
{{Server client function}}
This function sets the damage state of a specified door on a vehicle.
This function sets the state of the specified door on a vehicle.


==Syntax==
==Syntax==
<section name="Server and Client" class="both" show="true">
<syntaxhighlight lang="lua">bool setVehicleDoorState ( vehicle theVehicle, int door, int state )</syntaxhighlight>
<syntaxhighlight lang="lua">
{{OOP||[[vehicle]]:setDoorState||getVehicleDoorState}}
setVehicleDoorState ( vehicle theVehicle, int door, int state )
 
</syntaxhighlight>
{{New feature/item|9.0160|1.6.0|20319|
<syntaxhighlight lang="lua">bool setVehicleDoorState ( vehicle theVehicle, int door, int state [, bool spawnFlyingComponent = true ] )</syntaxhighlight>
}}


==Required Arguments==
==Required Arguments==
*'''theVehicle:''' The [[vehicle]] that you wish to change the door state of.
*'''theVehicle:''' The [[vehicle]] that you wish to change the door state of.
*'''door:''' An integer between 0 and 5 specifying the door you want to change state of.
*'''door:''' An integer representing which door to set the state of. Valid values are:
*'''state:''' A integer determining the new state of the door:
**'''0:''' Hood
**'''0:''' intact
**'''1:''' Trunk
**'''1:''' swinging free
**'''2:''' Front left
**'''2:''' bashed
**'''3:''' Front right
**'''3:''' bashed and swinging free
**'''4:''' Rear left
**'''4:''' missing
**'''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.0160|1.6.0|20319|
*'''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 the door state was successfully set, ''false'' if invalid arguments, invalid door IDs or invalid state IDs are passed.
Returns ''true'' if the door state was successfully set, ''false'' otherwise.
</section>


==Example==
==Example==
<section name="Server and Client" class="both" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
-- create a new vehicle
-- create a new vehicle
Line 31: Line 43:
state = setVehicleDoorState ( newcar, 2, 4 )
state = setVehicleDoorState ( newcar, 2, 4 )
</syntaxhighlight>
</syntaxhighlight>
</section>


==See Also==
==See Also==
{{Vehicle functions}}
{{Vehicle functions}}

Revision as of 01:15, 15 October 2019

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


ADDED/UPDATED IN VERSION 1.6.0 r20319:
bool setVehicleDoorState ( vehicle theVehicle, int door, int state [, bool spawnFlyingComponent = true ] )

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.

ADDED/UPDATED IN VERSION 1.6.0 r20319:
  • spawnFlyingComponent: A boolean, if set to true, spawns flying doors etc. if you remove a component with state == 4.

Returns

Returns true if the door state was successfully set, false otherwise.

Example

-- create a new vehicle
local newcar = createVehicle ( 520, 1024, 1024, 1024 )
-- break its front left door off
state = setVehicleDoorState ( newcar, 2, 4 )

See Also