Basic mission in sequence instead of random


#1

Hi I would like to make this mission do the jobs in sequence, in order from 1-30… Is anyone able to shed some light on how I would edit this code to do this… any help is greatly appreciated…

function LocalPed()
	return GetPlayerPed(-1)
end

local visitas = 1
local l = 0
local area = 0
local onjob = false

local destination = {
--AREA1

 {x =-1847.2933349609,y =-1317.0369873047,z =1.71848517656326, money = 8000},
 {x =-1903.5471191406,y =-1082.6751708984,z =1.2917383313179, money = 8000},
 {x =-828.01721191406,y =-1443.560546875,z =1.47430863976479, money = 8000},

----area 2
{x =-528.09118652344,y =-2545.9223632813,z =1.0960786342621, money = 8000},
{x =47.505973815918,y =-2319.8249511719,z =1.49322661757469, money = 8000},
{x =383.0451965332,y =-3044.3681640625,z =1.17996940016747, money = 8000},

--area3

{x =1527.6928710938,y =-2994.0549316406,z =1.89510536193848, money = 9000},
{x =1978.5102539063,y =-2775.8776855469,z =1.1195969581604, money = 9000},
{x =2291.6501464844,y =-2496.6005859375,z =1.054946724325418, money = 9000},

--area4

{x =2724.5778808594,y =-2127.9768066406,z =1.49966058135033, money = 9000},
{x =2740.5603027344,y =-1718.0686035156,z =1.26257231831551, money = 9000},

--area5

{x =2742.0307617188,y =-1000.6824951172,z =1.18312451243401, money = 9000},
{x =2869.4741210938,y =-628.23608398438,z =1.74840974807739, money = 9000},

--area6

{x =2901.0783691406,y =34.975120544434,z =1.81892603635788, money = 9000},
{x =3022.365234375,y =408.65948486328,z =1.21488007903099, money = 9000},

--area7

{x =2980.9919433594,y =6436.4545898438,z =1.25207915902138, money = 10000},
{x =2936.5148925781,y =1261.5250244141,z =1.2075552791357, money = 10000},
{x =3774.7631835938,y =4720.130859375,z =1.29373145103455, money = 10000},
{x =3569.5703125,y =979.3212890625,z =1.033762462437153, money = 10000},
--area8

{x =1267.5786132813,y =6691.1459960938,z =1.26194569468498, money = 10000},
{x =-386.24673461914,y =6621.8022460938,z =1.95269250869751, money = 10000},
{x =-799.82958984375,y =6088.2060546875,z =1.6689567565918, money = 10000},
{x =-990.65362548828,y =5666.4384765625,z =1.76397830247879, money = 10000},
--area9
{x =-1994.9758300781,y =4695.123046875,z =1.51996070146561, money = 10000},
{x =-2371.0278320313,y =4512.4536132813,z =1.89555311203003, money = 10000},
--area10
{x =1963.2219238281,y =112.32789611816,z =161.28271484375, money = 10000},
{x =-2887.4890136719,y =2772.6494140625,z =1.17472918331623, money = 10000},
{x =-2079.9060058594,y =2577.259765625,z =1.64592015743256, money = 10000},
{x =700.8154296875,y =4131.1752929688,z =30.813962936401, money = 10000},
{x =2166.4187011719,y =3979.5139160156,z =30.374570846558, money = 10000},
{x =-51.02596282959,y =678.25115966797,z =197.06451416016, money = 10000},

}

function drawTxt(text, font, centre, x, y, scale, r, g, b, a)
	SetTextFont(font)
	SetTextProportional(0)
	SetTextScale(scale, scale)
	SetTextColour(r, g, b, a)
	SetTextDropShadow(0, 0, 0, 0, 255)
	SetTextEdge(1, 0, 0, 0, 255)
	SetTextDropShadow()
	SetTextOutline()
	SetTextCentre(centre)
	SetTextEntry("STRING")
	AddTextComponentString(text)
	DrawText(x, y)
end

RegisterNetEvent("nodeliveryair")
AddEventHandler("nodeliveryair", function()
	SetNotificationTextEntry("STRING");
	AddTextComponentString("~r~You must register as a Dodo Pilot to start this job!" );
	DrawNotification(false, true);
end)

RegisterNetEvent("yesdeliveryair")
AddEventHandler("yesdeliveryair", function()
    SpawnVan()
	SetNotificationTextEntry("STRING");
	AddTextComponentString("~g~Dodo Air piloting started... Have a good route!" );
	DrawNotification(false, true);
end)

Citizen.CreateThread(function()
	while true do
		Citizen.Wait(0)
		DrawMarker(27, -1472.4487304688,-1440.8701171875,2.1497838497162 - 1, 0, 0, 0, 0, 0, 0, 3.0001, 3.0001, 1.5001, 255, 165, 0,165, 0, 0, 0,0)
		if GetDistanceBetweenCoords(-1472.4487304688,-1440.8701171875,2.1497838497162, GetEntityCoords(LocalPed())) < 2.0 then
			basiccheck()
		end
		if onjob == true then 
			if GetDistanceBetweenCoords(destination[l].x,destination[l].y,destination[l].z, GetEntityCoords(GetPlayerPed(-1))) < 30.0 then
				if IsVehicleModel(GetVehiclePedIsIn(GetPlayerPed(-1), true), GetHashKey("dodo"))  then
					drawTxt('Press ~g~E~s~ to deliver the ~b~ package', 2, 1, 0.5, 0.8, 0.6, 255, 255, 255, 255)
					if (IsControlJustReleased(1, 38)) then
						deliverysucces()
					end
				end
			end
		end
	end
end)

function basiccheck()
	if onjob == false then 
		if (IsInVehicle()) then
			if IsVehicleModel(GetVehiclePedIsIn(GetPlayerPed(-1), true), GetHashKey("dodo")) then
				drawTxt('Press ~g~Y~s~ to get more ~b~ Packages', 2, 1, 0.5, 0.8, 0.6, 255, 255, 255, 255)
				if (IsControlJustReleased(1, 246)) then
					TriggerServerEvent('delivery:checkjobair')
				end
			else
				drawTxt('Press ~g~Y~s~ to get a ~b~ Dodo seaplane', 2, 1, 0.5, 0.8, 0.6, 255, 255, 255, 255)
				if (IsControlJustReleased(1, 246)) then
				TriggerServerEvent('delivery:checkjobair')
				end
			end	
		else
			drawTxt('Press ~g~Y~s~ to take a ~b~ a sea plane', 2, 1, 0.5, 0.8, 0.6, 255, 255, 255, 255)
			if (IsControlJustReleased(1, 246)) then
				TriggerServerEvent('delivery:checkjobair')
			end
		end
	else
		drawTxt('Press ~g~H~s~ to cancel the contract~b~ at an extra cost', 2, 1, 0.5, 0.8, 0.6, 255, 255, 255, 255)
		if (IsControlJustReleased(1, 74)) then
			TriggerServerEvent('bank:withdrawAmende', destination[l].money)
			onjob = false
			RemoveBlip(deliveryblip)
			SetWaypointOff()
			visitas = 1
		end
	end
end

function IsInVehicle()
 local ply = GetPlayerPed(-1)
 if IsPedSittingInAnyVehicle(ply) then
 return true
 else
 return false
 end
end

function startjob()


	DisplayHelpText("Head to the area marked on the map.")
	onjob = true
area = math.random(1,10) 
if area == 1 then 
l = math.random(1,3)
end
if area == 2 then 
l = math.random(4,6)
end
if area == 3 then 
l = math.random(7,9)
end
if area == 4 then 
l = math.random(10,11)
end
if area == 5 then 
l = math.random(12,13)
end
if area == 6 then 
l = math.random(14,15)
end
if area == 7 then 
l = math.random(16,19)
end
if area == 8 then 
l = math.random(20,23)
end
if area == 9 then 
l = math.random(24,25)
end
if area == 10 then 
l = math.random(26,31)
end
	deliveryblip = (AddBlipForCoord(destination[l].x,destination[l].y,destination[l].z))
	SetBlipSprite(deliveryblip, 304)
	SetNewWaypoint(destination[l].x,destination[l].y)
end

function TextoSedex(text,font,centre,x,y,scale,r,g,b,a)
	SetTextFont(font)
	SetTextProportional(0)
	SetTextScale(scale, scale)
	SetTextColour(r, g, b, a)
	SetTextDropShadow(0, 0, 0, 0,255)
	SetTextEdge(1, 0, 0, 0, 255)
	SetTextDropShadow()
	SetTextOutline()
	SetTextCentre(centre)
	SetTextEntry("STRING")
	AddTextComponentString(text)
	DrawText(x , y)
end

function SpawnVan()
	if (IsInVehicle()) then
		if IsVehicleModel(GetVehiclePedIsIn(GetPlayerPed(-1), true), GetHashKey("dodo")) then
			startjob()
		end
	else
	Citizen.Wait(0)
	local myPed = GetPlayerPed(-1)
	local player = PlayerId()
	local vehicle = GetHashKey('dodo')

	RequestModel(vehicle)

	while not HasModelLoaded(vehicle) do
		Wait(1)
	end

	local plate = math.random(100, 900)
	local coords = GetOffsetFromEntityInWorldCoords(GetPlayerPed(-1), 0, 5.0, 0)
	local spawned_car = CreateVehicle(vehicle, coords, 90, true, false)
	SetVehicleOnGroundProperly(spawned_car)
	SetVehicleNumberPlateText(spawned_car, "POTATO"..plate)
	SetPedIntoVehicle(myPed, spawned_car, - 1)
	startjob()
	end
end

function deliverysucces()
TriggerServerEvent('delivery:successair',destination[l].money)
						if visitas == 5 then
							RemoveBlip(deliveryblip)
							onjob = false
							visitas = 1
							DisplayHelpText("Deliveries done, you can return to get more packages")
						else
							RemoveBlip(deliveryblip)
							startjob()
							visitas = visitas + 1
						end
end

local blips = {
	{title="Dodo Piloting", colour=38, id=478, x=-1472.448, y=-1440.87, z=2.14}, 
}

Citizen.CreateThread(function()
    for _, info in pairs(blips) do
      info.blip = AddBlipForCoord(info.x, info.y, info.z)
      SetBlipSprite(info.blip, info.id)
      SetBlipDisplay(info.blip, 4)
      SetBlipScale(info.blip, 0.9)
      SetBlipColour(info.blip, info.colour)
      SetBlipAsShortRange(info.blip, true)
	  BeginTextCommandSetBlipName("STRING")
      AddTextComponentString(info.title)
      EndTextCommandSetBlipName(info.blip)
    end
end)

function DisplayHelpText(str)
	SetTextComponentFormat("STRING")
	AddTextComponentString(str)
	DisplayHelpTextFromStringLabel(0, 0, 1, -1)
end