M MY Multiplayer: Wiki
Side
Kind

getVehicleDoorOpenRatio

Shared

Returns how far one or more doors of a vehicle are open.

float|table|false getVehicleDoorOpenRatio(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 open fraction, from 0 (shut) to 1 (fully open). 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("portamalas", function(player)
    local vehicle = getPedOccupiedVehicle(player)
    if not vehicle then return end
    if getVehicleDoorOpenRatio(vehicle, 1) > 0.5 then
        setVehicleDoorOpenRatio(vehicle, 1, 0, 800)
    else
        setVehicleDoorOpenRatio(vehicle, 1, 1, 800)
    end
end)

See also