IsVehicleWindowOpen: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Client function}}
{{Client function}}
{{Needs Example}}
{{New feature/item|3.0160|1.6|7405|This function gets the vehicle window state.}}
{{New feature/item|3.0160|1.6|7405|This function gets the vehicle window state.}}


Line 24: Line 23:


== Example ==
== Example ==
With this example, you can use /Window_vehicle to open, or close if it is open, the window of the local player's current seat.
<syntaxhighlight lang="lua">table = { 4, 2, 5, 3 }
<syntaxhighlight lang="lua">table = { 4, 2, 5, 3 }



Revision as of 21:31, 11 September 2015

This function gets the vehicle window state.

Syntax

bool isVehicleWindowOpen ( vehicle theVehicle, int window )

Required arguments

  • theVehicle: The vehicle that you wish to get the window state.
  • window: An integer representing a vehicle window. It can be:
    • 0: motorbike shield
    • 1: rear window
    • 2: right front window
    • 3: right back window
    • 4: left front (driver) window
    • 5: left back window
    • 6: windshield

Returns

This function returns a boolean which represents window open state.

Example

With this example, you can use /Window_vehicle to open, or close if it is open, the window of the local player's current seat.

table = { 4, 2, 5, 3 }

addCommandHandler ("Window_vehicle", function (  )
  if ( isPedInVehicle ( localPlayer ) ) then
 local vehicle = getPedOccupiedVehicle( localPlayer ) 
 local window = getPedOccupiedVehicleSeat( localPlayer )
 setVehicleWindowOpen( vehicle, table[window], not isVehicleWindowOpen( vehicle, table[window] ) )
	      end
    end
 )

See also