- Documentation
- Server functions
- setVehicleDoorOpenRatio
Function
setVehicleDoorOpenRatio
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
getVehicleDoorOpenRatioReturns the door opening degree set withsetVehicleDoorOpenRatio(0 = shut, 1 = open).setVehicleDoorStateSets the state of one door (or the bonnet or boot) of a vehicle for every player: shut, ajar, dented or missing. Door numbers: 0 bonnet, 1 boot, 2 front left, 3 front right, 4 rear left, 5 rear right. A vehicle without that door simply will not show it.