SetVehicleWindowOpen: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Client function}} {{New feature/item|3.0160|1.6|7405|This function sets the vehicle window state.}} == Syntax == <syntaxhighlight lang="lua"> bool setVehicleWindowOpen ( vehicle...")
 
Line 42: Line 42:
outputChatBox( "Window switched!" )
outputChatBox( "Window switched!" )
else
else
outputChatBox( "You don't have window! ")
outputChatBox( "You don't have window!")
end
end
else
else

Revision as of 10:54, 10 August 2015

This function sets the vehicle window state.

Syntax

bool setVehicleWindowOpen ( vehicle theVehicle, int window, bool open )

Required arguments

  • theVehicle: The vehicle that you wish to change the window state.
  • window: An integer representing window.
    • 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
  • open: Boolean which represent window open state.

Returns

  • True if vehicle is unstreamed and window ID is between valid values or when is streamed and has specified window.
  • False if vehicle is streamed and don't have specified window or window ID is not between valid values.

Example

Command which allow player to open window which near sits.

local seatWindows = {
	[0] = 4,
	[1] = 2,
	[2] = 5,
	[3] = 3
}

addCommandHandler("window",
	function()
		local veh = getPedOccupiedVehicle( localPlayer )
		if veh then
			local seat = getPedOccupiedVehicleSeat( localPlayer )
			if seatWindows[seat] and setVehicleWindowOpen( veh, seatWindows[seat], not isVehicleWindowOpen( veh, seatWindows[seat] ) ) then
				outputChatBox( "Window switched!" )
			else
				outputChatBox( "You don't have window!")
			end
		else
			outputChatBox( "You must be in vehicle!" )
		end
	end
)

See also