function DeliveryVehicle.getSkydiveDistances(V,g)local S={}for g=1,math.ceil(.3*g),1 do table.insert(S,V.randomGenerator:NextNumber(V.travelBeforeActive,V.travelBeforeActive+200))end for g=1,math.ceil(.25*g),1 do table.insert(S,V.randomGenerator:NextNumber(V.travelBeforeActive+200,V.travelDistance*.28571428571429))end for g=1,math.ceil(.2*g),1 do table.insert(S,V.randomGenerator:NextNumber(V.travelDistance*.28571428571429,V.travelDistance*.5))end for g=1,math.ceil(.15*g),1 do table.insert(S,V.randomGenerator:NextNumber(V.travelDistance*.5,V.travelUntilInactive))end for g=1,math.ceil(.1*g),1 do table.insert(S,100000)end table.sort(S)return S end function DeliveryVehicle.spawnSpecificPlayer(V,g)if not V.playersJumped[g]and tostring(PlayerMatchInfo.GetField(g,"\116\101\097\109\078\117\109\098\101\114"))==string.sub(V.currentModel.Name,16)then V.playersJumped[g]=true V:spawnPlayerFromVehicle(g)EventData:FireClient(g,"\069\120\105\116\101\100\068\101\108\105\118\101\114\121\086\101\104\105\099\108\101")end end function DeliveryVehicle.manageSkydivingForBots(g)(coroutine.wrap(function()local V={}for g,S in pairs(Players:GetPlayers())do if Util.playerIsBot(S)then table.insert(V,S)end end local S=g:getSkydiveDistances(#V)local I=1 while I<=#V and g:getCurrentPos()<g.travelUntilInactive do if S[I]<=g:getCurrentPos()then g:spawnSpecificPlayer(V[I])I=I+1 else wait()end end end))()end return DeliveryVehicle

function DeliveryVehicle:getSkydiveDistances(numBots)
	local skydiveTimes = {}
	for _ = 1, math.ceil(0.3 * numBots) do
		table.insert(skydiveTimes, self.randomGenerator:NextNumber(self.travelBeforeActive, self.travelBeforeActive + 200))
	end

	for _ = 1, math.ceil(0.25 * numBots) do
		table.insert(skydiveTimes, self.randomGenerator:NextNumber(self.travelBeforeActive + 200, self.travelDistance * (2 / 7)))
	end

	for _ = 1, math.ceil(0.2 * numBots) do
		table.insert(skydiveTimes, self.randomGenerator:NextNumber(self.travelDistance * (2 / 7), self.travelDistance * (1 / 2)))
	end

	for _ = 1, math.ceil(0.15 * numBots) do
		table.insert(skydiveTimes,self.randomGenerator:NextNumber(self.travelDistance * (1 / 2), self.travelUntilInactive))
	end

	for _ = 1, math.ceil(0.1 * numBots) do
		table.insert(skydiveTimes, 100000)
	end

	table.sort(skydiveTimes)

	return skydiveTimes
end

function DeliveryVehicle:spawnSpecificPlayer(player)
	if not self.playersJumped[player] and tostring(PlayerMatchInfo.GetField(player, "teamNumber")) == string.sub(self.currentModel.Name, 16) then
		self.playersJumped[player] = true
		self:spawnPlayerFromVehicle(player)
		EventData:FireClient(player, "ExitedDeliveryVehicle")
	end
end

function DeliveryVehicle:manageSkydivingForBots()
	coroutine.wrap(function()
		local botsInGame = {}
		for _, player in pairs(Players:GetPlayers()) do
			if Util.playerIsBot(player) then
				table.insert(botsInGame, player)
			end
		end
		local skydiveDistances = self:getSkydiveDistances(#botsInGame)

		local curID = 1
		while curID <= #botsInGame and self:getCurrentPos() < self.travelUntilInactive do -- stop trying to skydive players when skydiving period ends
			if skydiveDistances[curID] <= self:getCurrentPos() then
				self:spawnSpecificPlayer(botsInGame[curID])
				curID = curID + 1
			else
				wait()
			end
		end
	end)()
end

return DeliveryVehicle
