function init()
	switch = FindShape("switch")
	SetTag(switch, "interact", "Attach")
	jointlocation = FindShape("jointlocation")
	attached = false
	check = true
	vehiclefound = false
	isplayerinvehicle = false
	checkvehicle = true
	jointedvehicle = 0
	attachsound = LoadSound("MOD/snd/joint/caseopen.ogg")
	detachsound = LoadSound("MOD/snd/joint/closecase.ogg")
	attachedtovehicle = false 
end
function tick()
	pos = GetShapeWorldTransform(jointlocation).pos
	currentshape = GetPlayerInteractShape()
	if currentshape == switch and InputPressed("interact") then
		if attached == false then
			Spawn("MOD/vox/BP/joint.xml", Transform(pos), true, true)
			check=false 
			attached = true
			
			checkjoint = FindJoint("VJ")
			jointshapes = GetJointShapes(checkjoint)
			
			for i=1, #jointshapes do
				bodycheck = GetShapeBody(jointshapes[i])
				vehiclecheck = GetBodyVehicle(bodycheck)
					if vehiclecheck ~= 0 then
						attachedtovehicle = true
						RemoveTag(switch, "interact", "Attach")
						SetTag(switch, "interact", "Detach")
						PlaySound(attachsound)
					end
			end
			if attachedtovehicle == false then
				Delete(checkjoint)
				check=true
				attached = false
		    end
		end
		if attached == true and check == true then 
			vehiclejoint = FindJoint("VJ")
			Delete(vehiclejoint)
			attached = false
			RemoveTag(switch, "interact", "Detach")
			SetTag(switch, "interact", "Attach")
			PlaySound(detachsound)
			attachedtovehicle = false
		end
	end
	check = true
	currentvehicle = GetPlayerVehicle()
	vehiclebody = GetVehicleBody(currentvehicle)
	vehicleshapes = GetBodyShapes(vehiclebody)
	checkjoint = FindJoint("VJ")
	jointshapes = GetJointShapes(checkjoint)
	
	for i=1, #vehicleshapes do
		for b=1, #jointshapes do 
			if jointshapes[b] == vehicleshapes[i] then
				isplayerinvehicle = true
				jointedvehicle = GetPlayerVehicle()
				checkvehicle = false
			end
		end
	end
	if checkvehicle == true then 
		for i=1, #vehicleshapes do
			for b=1, #jointshapes do 
				if jointshapes[b] == vehicleshapes[i] then
					isplayerinvehicle = true
					jointedvehicle = GetPlayerVehicle()
					checkvehicle = false
				end
			end
		end
	end
	if attached == false then 
		checkvehicle = true 
	end
end