ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Server functions
  3. setVehicleDoorOpenRatio

Function

setVehicleDoorOpenRatio

ServerVehiclesIdentical to MTA:SA

Opens a door, the bonnet or the boot of a vehicle to the given degree for every player: 0 = shut, 1 = wide open, 0.5 = halfway. Useful e.g. in a workshop (open bonnet) or when searching the boot. Door numbering as in setVehicleDoorState.

Syntax

bool setVehicleDoorOpenRatio(vehicle vehicle, int door, float ratio [, int time = 0])

Arguments

vehiclevehicle
The vehicle.
doorint
Door number 0-5.
ratiofloat
Opening degree 0.0-1.0 (values outside are clamped).
timeint, optional = 0
Movement time in milliseconds (up to 60000). With 0 the door moves immediately. A player who sees the vehicle later gets the final state at once.

Returns

true on success.

Example

addCommandHandler("maska", function(player)
    local vehicle = getPedOccupiedVehicle(player)
    if vehicle then
        local open = getVehicleDoorOpenRatio(vehicle, 0) < 0.5
        setVehicleDoorOpenRatio(vehicle, 0, open and 1 or 0)
    end
end)

See also