M MY Multiplayer: Wiki
Side
Kind

getVehicleDoorState

Shared

Returns the state of one or more doors of a vehicle.

int|table|false getVehicleDoorState(vehicle vehicle, int|string|table door)

Parameters

NameTypeDescription
vehiclevehicleThe vehicle.
doorint|string|tableWhich door: its number (0 the front lid, 1 the rear lid, 2 and 3 the front doors on the driver's and the passenger's side, 4 and 5 the rear ones), its frame name (door_dside_f; left and right in place of dside and pside follow the vehicle's driving side), a group (all, side_doors, front_doors, rear_doors, left_doors, right_doors), -1 for all of them or a table of several.

Returns

The state (0 shut, 1 open, 2 shut and damaged, 3 open and damaged, 4 missing). When several doors were asked for (a group, -1 or a table), a table of frame name → value. false if the vehicle lacks one of the doors named.

Example

addCommandHandler("portas", function(player)
    local vehicle = getPedOccupiedVehicle(player)
    if not vehicle then return end
    local states = getVehicleDoorState(vehicle, "all")
    for frame, state in pairs(states) do
        outputDebugString(frame .. ": " .. state)
    end
end)

See also