function init()
	door_shapes = {}
	local handles
	local door_types = {"dslide"}
	for i=1, #door_types do
		handles = FindShapes(door_types[i])
		for j=1, #handles do
			door_shapes[#door_shapes+1] = {handle = handles[j], type = door_types[i], closed = true, joints = GetShapeJoints(handles[j]), grabbing = false}
		end
	end
	vehicle = FindVehicle("MPV")
	vehBody = FindBody("MPV_B")
	DoorAngle = 3
	MaxSlidingDoorDeviation = 0.05
	OpenedDoorSndChime = GetStringParam("OpenedDoorSndChimeFile", "MOD/ALS Scripts/sound/chime02.ogg")
	DoorOpeningSndFile = GetStringParam("DoorOpeningSndFile", "MOD/ALS Scripts/sound/DoorOpen.ogg")
	DoorClosingSnd = GetStringParam("DoorClosingSndFile", "MOD/ALS Scripts/sound/DoorClose.ogg")
	OpenedDoorSnd = LoadLoop(OpenedDoorSndChime)
	DoorOpeningSnd = LoadSound(DoorOpeningSndFile)
	DoorClosingSnd = LoadSound(DoorClosingSnd)
	OpenedDoorSignalization = GetBoolParam("OpenedDoorSignalization", false)
end
function tick()
	if IsHandleValid(vehicle) == true then
		com = GetBodyCenterOfMass(vehBody)
		BodyCenterPos = TransformToParentPoint(GetBodyTransform(vehBody), com)
		vehPos = VecAdd(BodyCenterPos, Vec(0,1,0))
		for i=1, #door_shapes do
			door_shapes[i].pos = GetShapeWorldTransform(door_shapes[i].handle).pos
		end
		for i=1, #door_shapes do
			door_shapes[i].angle = GetJointMovement(door_shapes[i].joints[1])
		end
		function chime()
			if GetPlayerVehicle() == vehicle and GetVehicleHealth(vehicle) > 0.2 then
				PlayLoop(OpenedDoorSnd, vehPos, 1)
			end
		end
		for i=1, #door_shapes do
			if GetPlayerGrabShape() == door_shapes[i].handle then
				door_shapes[i].grabbing = true
			else
				door_shapes[i].grabbing = false
			end
		end
		for i=1, #door_shapes do
			if door_shapes[i].grabbing then
				for j=1, #door_shapes[i].joints do
					SetJointMotor(door_shapes[i].joints[j], 0, 0)
				end
			else
				local closeThreshold = false
				if door_shapes[i].type == "dslide" then 
					if door_shapes[i].angle < MaxSlidingDoorDeviation then
						closeThreshold = true
					end
				else
					if door_shapes[i].angle < DoorAngle then
						closeThreshold = true
					end
				end

				if closeThreshold then
					for j=1, #door_shapes[i].joints do
						SetJointMotor(door_shapes[i].joints[j], 1)
					end
				else
					for j=1, #door_shapes[i].joints do
						SetJointMotor(door_shapes[i].joints[j], 0, 0)
					end
				end
			end
			if door_shapes[i].type == "dslide" then
				if door_shapes[i].angle < MaxSlidingDoorDeviation then
					if door_shapes[i].closed == false then
						PlaySound(DoorClosingSnd, door_shapes[i].pos, 1)
						door_shapes[i].closed = true
					end
				else
					if door_shapes[i].closed == true and door_shapes[i].angle > 0.05 then
						PlaySound(DoorOpeningSnd, door_shapes[i].pos, 1)
						door_shapes[i].closed = false
					end
				end
			else
				if door_shapes[i].angle < DoorAngle then
					if door_shapes[i].closed == false then
						PlaySound(DoorClosingSnd, door_shapes[i].pos, 1)
						door_shapes[i].closed = true
					end
				else
					if door_shapes[i].closed == true and door_shapes[i].angle > 0.7 then
						PlaySound(DoorOpeningSnd, door_shapes[i].pos, 1)
						door_shapes[i].closed = false
					end
				end
			end
			if (not door_shapes[i].closed) and door_shapes[i].type ~= "dlatch" then
				chime()
			end
		end
	end
end
