local garbageTruckSpawn = {x = -346.45980834961, y = -1560.9096679688, z = 24.945465087891, h = 90.577255249023}
local garbageJobLocation = {x = -349.69494628906, y = -1569.5640869141, z = 25.224782943726}
local currentPickup = false
local totalGarbageCollected = 0
local requiredGarbageCollected = 0
local trashTruck = false

garbageLocations = {
	{815.4970703125,-2944.93627929688,5.81979990005493},
	{453.689544677734,-3037.39599609375,5.932692527771},
	{599.167053222656,-2924.31689453125,5.91073703765869},
	{631.211608886719,-2814.67114257813,5.91806888580322},
	{634.657104492188,-2707.640625,5.94811296463013},
	{601.615173339844,-2770.8583984375,5.91961908340454},
	{490.8017578125,-2707.19140625,5.92152833938599},
	{824.793334960938,-2485.912109375,23.5775356292725},
	{992.295837402344,-2543.72338867188,28.1659259796143},
	{951.575744628906,-2536.94140625,28.1659088134766},
	{1051.03259277344,-2469.29541015625,28.3691711425781},
	{1068.29675292969,-2460.07788085938,28.6974582672119},
	{711.756164550781,-934.775390625,24.0492935180664},
	{714.294799804688,-928.281127929688,23.9951915740967},
	{287.5634765625,-613.65966796875,42.9239158630371},
	{712.973266601563,-919.425720214844,23.7811641693115},
	{50.1719512939453,-834.70849609375,30.3728904724121},
	{70.2880325317383,-873.812561035156,29.9872798919678},
	{693.892272949219,-853.024841308594,24.1752548217773},
	{163.312530517578,-777.094665527344,31.2805156707764},
	{715.6728515625,-849.486022949219,24.2969131469727},
	{235.919952392578,-679.341857910156,36.7252311706543},
	{746.23388671875,-838.606262207031,25.4589996337891},
	{711.345092773438,-826.822082519531,24.4288387298584},
	{725.035034179688,-788.460144042969,24.9005813598633},
	{714.749633789063,-786.982299804688,26.2714138031006},
	{724.373229980469,-744.025939941406,25.7984027862549},
	{241.405487060547,-826.83544921875,29.50266456604},
	{724.25109863282,-744.67016601562,25.770078659058},
	{293.872009277344,-812.9677734375,28.8023109436035},
	{735.467651367188,-720.115478515625,26.6933937072754},
	{703.190979003906,-719.440246582031,26.0239734649658},
	{705.042419433594,-726.557250976563,25.6248359680176},
	{699.923034667969,-726.554321289063,25.498025894165},
	{682.134521484375,-725.693603515625,25.0599250793457},
	{316.233520507813,-741.07763671875,28.7704544067383},
	{719.412048339844,-690.050964355469,26.9077854156494},
	{719.162414550781,-697.084594726563,26.7430305480957},
	{448.973754882813,-576.954895019531,28.0083866119385},
	{700.713623046875,-643.487670898438,26.7135753631592},
	{472.719451904297,-601.381164550781,28.0093517303467},
	{685.197021484375,-643.956176757813,25.5767211914063},
	{454.164276123047,-696.887573242188,27.1232433319092},
	{744.892395019531,-646.001831054688,28.5115604400635},
	{749.701538085938,-644.186767578125,28.7953414916992},
	{410.237213134766,-795.931640625,28.7213325500488},
	{396.942077636719,-742.770751953125,28.7870979309082},
	{398.507385253906,-720.070129394531,28.7966728210449},
	{-557.725524902344,-706.608520507813,32.7987480163574},
	{375.128784179688,-842.763549804688,28.7312755584717},
	{369.219604492188,-834.706115722656,28.8016395568848},
	{806.653442382813,-487.828643798828,30.2985992431641},
	{816.086303710938,-484.848693847656,30.2192306518555},
	{401.122985839844,-912.948059082031,28.8766841888428},
	{-860.756042480469,-243.269454956055,39.1033706665039},
	{467.796905517578,-950.550231933594,27.2830238342285},
	{-967.602905273438,-188.191940307617,37.4316673278809},
	{835.640625,-807.9052734375,26.2931613922119},
	{837.892333984375,-814.012939453125,27.2062835693359},
	{451.740295410156,-932.295104980469,27.9954624176025},
	{823.202758789063,-802.015502929688,26.3953113555908},
	{451.355407714844,-916.987182617188,27.9597434997559},
	{814.601745605469,-829.574096679688,27.0342788696289},
	{804.388549804688,-830.287719726563,26.2232227325439},
	{492.976043701172,-997.797607421875,27.2799854278564},
	{848.304382324219,-906.6826171875,25.2514762878418},
	{480.184326171875,-1065.70935058594,28.7215156555176},
	{852.763000488281,-934.431945800781,26.2823677062988},
	{830.032043457031,-920.971984863281,26.0012302398682},
	{342.841613769531,-1101.04919433594,28.9143772125244},
	{-1415.73474121094,-397.753112792969,35.8306655883789},
	{-1522.61303710938,-458.745147705078,35.0492401123047},
	{-1518.83813476563,-413.867279052734,35.0625457763672},
	{-1588.80920410156,-472.565063476563,35.808765411377},
	{339.114440917969,-1079.01574707031,29.002498626709},
	{-1565.64599609375,-424.214233398438,37.4958229064941},
	{434.66015625,-1066.37060546875,28.7224788665771},
	{453.533294677734,-1071.90661621094,28.7209987640381},
	{-1788.56103515625,-495.177307128906,38.3920364379883},
	{480.707305908203,-1074.31176757813,28.7167224884033},
	{377.564971923828,-1115.44714355469,28.9142837524414},
	{759.702331542969,-1231.82751464844,24.9679908752441},
	{738.230346679688,-1235.29968261719,25.2289657592773},
	{48.7559661865234,-1047.30822753906,29.1335678100586},
	{35.8783950805664,-1010.31658935547,28.9732246398926},
	{6.02779388427734,-1032.43640136719,28.6646709442139},
	{731.169006347656,-1416.02844238281,27.0758361816406},
	{841.472351074219,-1412.78979492188,26.2398128509521},
	{844.451538085938,-1412.7177734375,26.085111618042},
	{848.278198242188,-1412.57861328125,26.085470199585},
	{-1750.40112304688,-375.733764648438,45.6485366821289},
	{-1615.15026855469,-507.174835205078,35.2647018432617},
	{-1512.00732421875,-655.514282226563,28.7997817993164},
	{-1460.8858642578,-626.4603881836,30.757642745972},
	{-6.77977180480957,-1083.26330566406,26.1826992034912},
	{-1427.02746582031,-657.010070800781,28.2910442352295},
	{-1422.20056152344,-652.5517578125,28.2890167236328},
	{926.849853515625,-1550.39709472656,30.8390274047852},
	{-1406.90270996094,-635.784606933594,28.290548324585},
	{-1400.23583984375,-639.199279785156,28.2913379669189},
	{-1390.74829101563,-646.525329589844,28.2869110107422},
	{-1379.95434570313,-642.876572265625,28.2909355163574},
	{955.519775390625,-1578.74548339844,30.40944480896},
	{947.088073730469,-1578.92626953125,30.3390064239502},
	{17.0313301086426,-1122.46301269531,28.3927059173584},
	{972.826843261719,-1703.35131835938,30.4275531768799},
	{983.982360839844,-1539.59448242188,30.693187713623},
	{988.052734375,-1540.66857910156,30.7876892089844},
	{-1645.150390625,-982.500549316406,7.02812433242798},
	{954.247619628906,-1514.49243164063,31.2506809234619},
	{951.027770996094,-1511.16015625,30.924955368042},
	{949.482666015625,-1495.54943847656,30.724365234375},
	{-1605.79516601563,-817.239318847656,9.58956718444824},
	{951.322143554688,-1490.8359375,32.0217247009277},
	{932.292114257813,-1498.11193847656,30.2952308654785},
	{936.561706542969,-1505.82275390625,30.5456390380859},
	{937.736694335938,-1507.07287597656,30.5803985595703},
	{-1297.57299804688,-1149.74304199219,5.02883768081665},
	{-1260.40502929688,-1171.54272460938,6.19061946868896},
	{-1281.84326171875,-1212.22778320313,4.19930982589722},
	{475.662689208984,-1283.63452148438,29.0501194000244},
	{483.957855224609,-1280.45910644531,29.0493030548096},
	{-1228.75891113281,-1221.87475585938,6.51755619049072},
	{-1256.12194824219,-1278.62219238281,3.45863199234009},
	{379.923950195313,-1266.25830078125,31.9802646636963},
	{-1290.69799804688,-1293.5849609375,3.86300182342529},
	{364.59100341796,-1285.2479248046,32.408641815186},
	{-1286.79748535156,-1321.50366210938,3.89997005462646},
	{-1261.59765625,-1372.68469238281,3.68531036376953},
	{-1251.64916992188,-1378.3623046875,3.57935404777527},
	{433.663879394531,-1457.69787597656,28.8034019470215},
	{-1216.28186035156,-1425.8369140625,3.91743969917297},
	{-1189.07702636719,-1508.14123535156,3.95486545562744},
	{-1152.18334960938,-1538.24645996094,3.87877559661865},
	{-1154.75024414063,-1554.7890625,3.8543267250061},
	{-1085.10498046875,-1592.0224609375,3.86512541770935},
	{295.596832275391,-1239.53100585938,28.7878246307373},
	{-977.198669433594,-1586.46875,4.60146856307983},
	{304.567535400391,-1294.52856445313,30.2609462738037},
	{334.458465576172,-1275.29577636719,31.3227462768555},
	{-937.125122070313,-1570.06323242188,4.80430126190186},
	{-947.123657226563,-1546.5673828125,4.6727819442749},
	{-923.253173828125,-1533.04345703125,4.59719562530518},
	{162.721069335938,-1284.74035644531,28.7185020446777},
	{-884.179626464844,-1518.08923339844,4.79965591430664},
	{153.091644287109,-1306.03991699219,28.7123603820801},
	{-894.319213867188,-1494.68884277344,4.67528438568115},
	{138.770568847656,-1312.18432617188,28.6390171051025},
	{-931.833801269531,-1507.96826171875,4.67517948150635},
	{144.955825805664,-1287.35473632813,28.8395366668701},
	{1442.02026367188,-1676.74072265625,65.3814468383789},
	{1434.84326171875,-1687.73718261719,65.4268341064453},
	{-1098.4951171875,-1288.33874511719,5.04360580444336},
	{-1074.904296875,-1275.13708496094,5.40246105194092},
	{142.192565917969,-1262.58972167969,28.7902717590332},
	{1475.11962890625,-1787.82983398438,70.8288497924805},
	{1465.71911621094,-1734.69848632813,68.3438339233398},
	{89.5488433837891,-1281.90441894531,28.7267246246338},
	{81.4011154174805,-1292.85290527344,28.8051109313965},
	{-846.277954101563,-1116.00012207031,6.637291431427},
	{89.4491500854492,-1306.28283691406,28.7937431335449},
	{1456.9306640625,-1650.74682617188,66.998664855957},
	{106.440322875977,-1320.77160644531,28.7550868988037},
	{119.26358795166,-1324.23815917969,28.8762092590332},
	{138.236511230469,-1365.18640136719,28.8154449462891},
	{1579.6162109375,-1718.19030761719,88.1522674560547},
	{1581.14453125,-1726.26245117188,88.1510696411133},
	{-11.3846254348755,-1305.92761230469,28.7270221710205},
	{-21.7133159637451,-1298.16821289063,28.8476600646973},
	{1559.58935546875,-1680.90844726563,88.2504501342773},
	{-41.4999771118164,-1299.63854980469,28.6695938110352},
	{-41.715461730957,-1285.79272460938,28.6740264892578},
	{-559.141906738281,-705.442443847656,32.6703758239746},
	{-79.1958541870117,-1263.36376953125,28.4536952972412},
	{-52.8805847167969,-1263.09680175781,28.4673633575439},
	{-358.627960205078,-644.264038085938,31.3209171295166},
	{-48.936824798584,-1319.18371582031,28.5784702301025},
	{-69.965705871582,-1317.18591308594,28.5494289398193},
	{-79.8945159912109,-1316.68542480469,28.618537902832},
	{-89.583740234375,-1329.52270507813,28.8270702362061},
	{-359.364135742188,-958.549072265625,30.6562690734863},
	{-150.403427124023,-1296.73559570313,30.5125865936279},
	{-169.568939208984,-1297.64721679688,30.5903511047363},
	{-178.264373779297,-1287.61645507813,30.8064117431641},
	{-152.471420288086,-1252.17980957031,30.8060188293457},
	{-127.715553283691,-1339.25170898438,29.1757144927979},
	{-151.665740966797,-1345.14184570313,29.4025859832764},
	{-334.717681884766,-1530.92260742188,27.5615901947021},
	{-242.40055847168,-1346.53051757813,30.5442810058594},
	{-326.633148193359,-1523.92077636719,27.5375747680664},
	{-151.70458984375,-1411.91430664063,30.2531566619873},
	{-101.477401733398,-1413.03186035156,29.1205101013184},
	{-78.8683471679688,-1406.42114257813,28.8314628601074},
	{-77.8367309570313,-1390.62158203125,28.8311195373535},
	{-81.341438293457,-1426.38684082031,29.1662788391113},
	{-53.5956687927246,-1419.05517578125,28.8368968963623},
	{-29.5894088745117,-1418.82934570313,28.8279247283936},
	{-14.1795864105225,-1390.07971191406,28.9098625183105},
	{-28.352668762207,-1354.56628417969,28.6689472198486},
	{-39.3966255187988,-1354.30236816406,28.7612476348877},
	{-50.3576049804688,-1353.64465332031,28.8459453582764},
	{14.7340450286865,-1413.08276367188,28.8591232299805},
	{63.788688659668,-1394.39575195313,28.8919315338135},
	{49.0810737609863,-1384.36340332031,28.8013973236084},
	{98.6012573242188,-1441.29553222656,28.7127285003662},
	{79.0463638305664,-1463.86022949219,28.6905040740967},
	{66.4101028442383,-1471.87194824219,28.8127384185791},
	{334.292755126953,267.357727050781,104.043235778809},
	{45.8176002502441,-1480.12817382813,28.7990703582764},
	{37.9141426086426,-1451.70031738281,28.8223915100098},
	{5.45189619064331,-562.522216796875,37.1962471008301},
	{52.5213890075684,-1435.64855957031,28.8207683563232},
	{-73.3010406494141,-168.240661621094,52.6126594543457},
	{-62.0035209655762,-183.769958496094,51.5617904663086},
	{-45.7523536682129,-192.078811645508,51.8018417358398},
	{-32.5162887573242,-194.041778564453,51.9828681945801},
	{-20.1824340820313,-199.971420288086,51.9811477661133},
	{-92.924430847168,-1467.88610839844,32.5793228149414},
	{-7.21501636505127,-207.699905395508,52.3061180114746},
	{0.685307562351227,-207.893280029297,52.3654823303223},
	{-112.50008392334,-1450.630859375,32.9406318664551},
	{-72.431510925293,-1.48289954662323,69.7615814208984},
	{-151.648651123047,-1412.15942382813,30.2560443878174},
	{-90.4968566894531,-48.9370994567871,61.8186225891113},
	{-166.059936523438,-1415.22253417969,30.4851818084717},
	{-42.1602554321289,-49.4744720458984,63.0074119567871},
	{-189.045211791992,-1376.72277832031,30.7720909118652},
	{-57.7605171203613,206.2431640625,101.599349975586},
	{-173.786437988281,-1461.34899902344,31.2870998382568},
	{103.965515136719,320.745758056641,111.724639892578},
	{114.412109375,322.653656005859,111.752365112305},
	{-148.407562255859,-1462.564453125,32.8704948425293},
	{124.738464355469,311.55126953125,111.758239746094},
	{-141.117904663086,-1452.20581054688,32.9761772155762},
	{141.941345214844,309.684417724609,111.756088256836},
	{-112.183212280273,-1451.39208984375,32.9457893371582},
	{-92.6996688842773,-1467.23046875,32.5722007751465},
	{220.191802978516,387.989013671875,106.324295043945},
	{252.945907592773,378.417724609375,105.152626037598},
	{207.191253662109,342.084259033203,105.24543762207},
	{197.046615600586,339.160797119141,105.451416015625},
	{-227.83447265625,-1634.74169921875,33.0268707275391},
	{345.679016113281,-1105.35375976563,29.0121593475342},
	{339.795837402344,-1076.56079101563,29.1318397521973},
	{-367.282165527344,-86.677001953125,45.2326507568359},
	{-284.972320556641,-96.7767181396484,46.5885200500488},
	{1073.576171875,-2462.02368164063,28.9232921600342},
	{-356.359893798828,-64.6477661132813,53.9984931945801},
	{1060.50964355469,-2463.11450195313,28.6803131103516},
	{-513.8314819336,-41.079528808591,44.515544891358},
	{1050.58483886719,-2465.21752929688,28.5070171356201},
	{1046.14514160156,-2468.46508789063,28.5213775634766},
	{-83.7159042358398,-49.0321502685547,61.168758392334},
	{-48.3186912536621,-45.7022743225098,62.8333358764648},
	{-76.2146911621094,-24.9477519989014,65.7336044311523},
	{-70.8937072753906,-2.07449555397034,69.8364868164063},
	{-55.2623138427734,204.333404541016,101.667701721191},
	{-73.2698822021484,-164.564880371094,53.224292755127},
	{-72.1416091918945,206.244155883789,96.026008605957},
	{-60.3388595581055,-184.443283081055,51.5628814697266},
	{-44.5871696472168,-192.704238891602,51.7267532348633},
	{-115.537033081055,216.619842529297,94.35888671875},
	{-70.2697296142578,187.56803894043,87.1110534667969},
	{-80.6591339111328,85.8964233398438,71.1946563720703},
	{-103.513107299805,48.6521110534668,71.2726364135742},
	{-141.62532043457,-21.2421436309814,57.670352935791},
	{-169.071075439453,-46.0207862854004,52.3598861694336},
	{-226.313934326172,5.38673448562622,52.2068138122559},
	{-29.5211658477783,-192.352798461914,51.8653907775879},
	{-20.4928932189941,-198.358337402344,51.872875213623},
	{-5.47572660446167,-208.007873535156,52.2376022338867},
	{3.98909974098206,-205.954040527344,52.2522888183594},
	{23.6965160369873,-207.408981323242,52.367057800293},
	{-29.228630065918,-87.1500396728516,56.7634696960449},
	{-38.9540367126465,-48.4523048400879,63.0712394714355},
	{-79.7849731445313,1.02873504161835,69.7364501953125},
	{-204.63948059082,213.825698852539,86.464225769043},
	{-179.105606079102,209.051483154297,87.997314453125},
	{-82.3177337646484,-19.9973602294922,65.8320770263672},
	{-148.26286315918,205.512725830078,91.6920776367188},
	{-181.585159301758,247.664962768555,92.3710098266602},
	{-218.68049621582,271.091278076172,91.6061172485352},
	{-226.677459716797,293.131317138672,91.7465744018555},
	{-257.062347412109,292.055297851563,91.3128509521484},
	{98.3697814941406,302.444213867188,109.530380249023},
	{-297.414276123047,319.525543212891,92.9465866088867},
	{-387.711456298828,289.361938476563,84.5822067260742},
	{19.7930793762207,371.693115234375,111.876289367676},
	{-412.121887207031,291.642761230469,82.9203796386719},
	{-458.461761474609,299.705017089844,82.9319076538086},
	{-448.503234863281,292.511596679688,82.9269943237305},
	{-476.388519287109,301.058837890625,82.8983001708984},
	{-495.361236572266,303.5205078125,82.9218902587891},
	{-472.589538574219,759.082336425781,168.80012512207},
	{-507.810302734375,304.598999023438,82.8554763793945},
	{-471.213775634766,270.455596923828,82.9089813232422},
	{-515.479919433594,267.945251464844,82.6894836425781},
	{-760.402465820313,688.173522949219,143.556243896484},
	{-801.297790527344,844.122680664063,203.493774414063},
	{-552.576110839844,306.2197265625,82.6842956542969},
	{-1255.48193359375,651.350524902344,140.356246948242},
	{-1136.81091308594,557.789001464844,101.414726257324},
	{-1248.33935546875,465.026550292969,92.7288131713867},
	{-269.259765625,196.605865478516,85.2693023681641},
	{294.384246826172,-1241.38562011719,29.2641983032227},
	{-370.577606201172,184.982894897461,79.9552917480469},
	{-421.606964111328,182.812088012695,80.220832824707},
	{-1410.73278808594,-256.169830322266,45.8790168762207},
	{-1432.91064453125,-392.862182617188,35.8359489440918},
	{-1444.47033691406,-378.410339355469,37.7956199645996},
	{-767.931945800781,-218.327529907227,36.581413269043},
	{3.94461297988892,-1826.25170898438,24.7385368347168},
	{623.110595703125,207.677368164063,98.2034912109375},
	{616.268249511719,188.875457763672,97.7633972167969},
	{600.547607421875,149.365325927734,97.4317169189453},
	{40.3463363647461,-1881.82312011719,21.802885055542},
	{79.4203109741211,-1928.73034667969,20.3036575317383},
	{663.6669921875,207.773468017578,94.4062576293945},
	{-687.498352050781,-153.810638427734,36.9621620178223},
	{116.029846191406,-1943.50512695313,20.1127262115479},
	{-679.170776367188,-166.345596313477,36.9742012023926},
	{132.61457824707,-1881.05078125,23.0752353668213},
	{191.715637207031,-1913.21447753906,22.3885288238525},
	{155.223098754883,-1975.541015625,17.8088226318359},
	{193.55810546875,-2016.67919921875,17.7987632751465},
	{216.28532409668,-2013.89575195313,18.3765544891357},
	{205.218185424805,-2001.69958496094,18.369441986084},
	{793.283325195313,-980.920532226563,26.1072807312012},
	{737.577087402344,-986.19140625,24.4595718383789},
	{758.561401367188,-1030.92272949219,20.8395233154297},
	{343.933532714844,-1038.59399414063,29.167989730835},
	{1056.92700195313,-2209.30053710938,30.2220077514648},
	{1042.59838867188,-2183.05297851563,31.2212677001953},
	{1013.54010009766,-2065.43725585938,30.9004440307617},
	{1057.21057128906,-1824.33056640625,37.1590232849121},
	{1262.52429199219,-1903.07470703125,38.3459281921387},
	{1370.39147949219,-2082.63793945313,51.8448944091797},
	{1385.49377441406,-2045.25231933594,51.8446998596191},
	{1572.37585449219,-1695.28503417969,88.0460815429688},
	{1729.93579101563,-1636.81469726563,112.378387451172},
	{891.23681640625,-1580.99523925781,30.6484470367432},
	{355.071105957031,-1867.09545898438,26.4428863525391},
	{866.307067871094,-1606.80737304688,30.1976661682129},
	{393.933074951172,-1815.91223144531,28.4631881713867},
	{357.157073974609,-1808.72680664063,28.4526023864746},
	{850.843627929688,-1983.06201171875,29.3013458251953},
	{819.276123046875,-1978.03369140625,29.2772445678711},
	{532.741943359375,-1762.65783691406,28.2514953613281},
	{-551.498474121094,-40.5846290588379,41.878532409668},
	{881.246643066406,-1998.3134765625,30.447208404541},
	{-531.265258789063,-41.5636978149414,41.725212097168},
	{-502.288360595703,-51.1499786376953,39.4579620361328},
	{431.407684326172,-1874.296875,26.5981159210205},
	{420.389373779297,-1881.05297851563,25.8699779510498},
	{868.588195800781,-2196.56469726563,30.500732421875},
	{-489.852783203125,-55.0540008544922,39.2912063598633},
	{531.057556152344,-124.367462158203,61.0433235168457},
	{888.25439453125,-2174.14501953125,30.519344329834},
	{338.300750732422,-1964.44519042969,23.9847316741943},
	{898.58740234375,-2181.564453125,30.8060703277588},
	{-461.191284179688,-51.9204559326172,43.8133811950684},
	{521.105407714844,-160.55094909668,55.9081573486328},
	{303.864349365234,-1998.75756835938,20.3308029174805},
	{834.312744140625,-2180.14453125,30.30029296875},
	{303.792205810547,-2019.1865234375,19.7035942077637},
	{337.746795654297,-2037.30224609375,20.8211936950684},
	{286.951538085938,-612.53125,42.9896430969238},
	{312.75341796875,-2016.08081054688,19.9318542480469},
	{809.117919921875,-2118.40234375,29.3373222351074},
	{246.17024230957,-656.890808105469,38.4258270263672},
	{266.536468505859,-2044.28491210938,17.3732280731201},
	{234.488708496094,-681.050476074219,36.7399139404297},
	{265.482025146484,-2058.30859375,16.9362545013428},
	{165.760208129883,-776.801696777344,31.4212322235107},
	{856.241577148438,-2201.66845703125,30.6700439453125},
	{239.803604125977,-826.16552734375,29.6407527923584},
	{284.850616455078,-2093.67333984375,16.203685760498},
	{376.478088378906,-837.052062988281,28.8979053497314},
	{409.943756103516,-796.025817871094,28.8373870849609},
	{896.159973144531,-2238.1552734375,30.5270195007324},
	{395.22048950195,-739.57928466796,29.27671839648},
	{397.690826416016,-720.183288574219,28.8918361663818},
	{397.849853515625,-719.63818359375,28.8923358917236},
	{413.903625488281,-2070.54370117188,21.0171794891357},
	{-255.745330810547,-227.074447631836,35.9162826538086},
	{446.726409912109,-578.576843261719,28.1057186126709},
	{956.632507324219,-2184.56884765625,30.5578556060791},
	{948.756713867188,-2173.15625,30.5516910552979},
	{469.235168457031,-599.176086425781,28.1057415008545}
}

local pickedupTrash = false
local currentBlip = false
function getNewWaypoint()
	currentPickup = math.random(1, #garbageLocations)
	if currentBlip then
		RemoveBlip(currentBlip)
	end
	currentBlip = AddBlipForCoord(garbageLocations[currentPickup][1],  garbageLocations[currentPickup][2],  garbageLocations[currentPickup][3])
	SetBlipSprite(currentBlip, 1)
	SetBlipColour(currentBlip, 1)
	SetBlipRouteColour(currentBlip, 1)
	SetBlipRoute(currentBlip,  true)
end
function getReturnWaypoint()
	if currentBlip then
		RemoveBlip(currentBlip)
	end
	currentBlip = AddBlipForCoord(garbageTruckSpawn.x, garbageTruckSpawn.y, garbageTruckSpawn.z)
	SetBlipSprite(currentBlip, 1)
	SetBlipColour(currentBlip, 3)
	SetBlipRouteColour(currentBlip, 1)
	SetBlipRoute(currentBlip,  true)
end
function fsn_lookingAt()
	local targetVehicle = false

	local coordA = GetEntityCoords(PlayerPedId(), 1)
	local coordB = GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0.0, 20.0, -1.0)
	targetVehicle = getVehicleInDirection(coordA, coordB)

	return targetVehicle
end

Citizen.CreateThread(function()
	-- blip stuff
	local blip = AddBlipForCoord(garbageTruckSpawn.x, garbageTruckSpawn.y, garbageTruckSpawn.z)
	SetBlipSprite(blip,318)
	BeginTextCommandSetBlipName("STRING")
	AddTextComponentString('Garbage')
	EndTextCommandSetBlipName(blip)
	SetBlipAsShortRange(blip,true)
	SetBlipAsMissionCreatorBlip(blip,true)
	
	-- job stuff
	while true do Citizen.Wait(0)
		if currentPickup and pickedupTrash then
			if fsn_lookingAt() == trashTruck then
				SetTextComponentFormat("STRING")
				AddTextComponentString("Press ~INPUT_PICKUP~ to put the trash in the truck")
				DisplayHelpTextFromStringLabel(0, 0, 1, -1)
				if IsControlJustPressed(0,38) then
					pickedupTrash = false
					if totalGarbageCollected >= requiredGarbageCollected then
						getReturnWaypoint()
					else
						totalGarbageCollected = totalGarbageCollected + 1
						TriggerEvent('fsn_notify:displayNotification', 'You completed pickup '..totalGarbageCollected..'/'..requiredGarbageCollected+1, 'centerRight', 4000, 'info')
						getNewWaypoint()
					end
				end
			end
		end
		if currentPickup and GetDistanceBetweenCoords(garbageLocations[currentPickup][1],garbageLocations[currentPickup][2],garbageLocations[currentPickup][3],GetEntityCoords(PlayerPedId()), true) < 10 then
			if not pickedupTrash then
				DrawMarker(1,garbageLocations[currentPickup][1],garbageLocations[currentPickup][2],garbageLocations[currentPickup][3],0,0,0,0,0,0,1.001,1.0001,0.4001,0,155,255,175,0,0,0,0)
			end
			if GetDistanceBetweenCoords(garbageLocations[currentPickup][1],garbageLocations[currentPickup][2],garbageLocations[currentPickup][3],GetEntityCoords(PlayerPedId()), false) < 2 then
				if not pickedupTrash then
					if not IsPedInAnyVehicle(PlayerPedId()) then
						SetTextComponentFormat("STRING")
						AddTextComponentString("Press ~INPUT_PICKUP~ to pick up the trash")
						DisplayHelpTextFromStringLabel(0, 0, 1, -1)
						if IsControlJustPressed(0,38) then
							while not HasAnimDictLoaded('pickup_object') do
							RequestAnimDict('pickup_object')
							Citizen.Wait(5)
						  end
						  TaskPlayAnim(PlayerPedId(), 'pickup_object', 'pickup_low', 8.0, 1.0, -1, 49, 1.0, 0, 0, 0)
						  Citizen.Wait(1000)
						  ClearPedTasks(PlayerPedId())
						  TriggerEvent('fsn_notify:displayNotification', 'Put the trash in your van and head to the next spot', 'centerRight', 4000, 'info')
						  pickedupTrash = true
						end
					else
						SetTextComponentFormat("STRING")
						AddTextComponentString("~r~You cannot pickup trash from inside the truck")
						DisplayHelpTextFromStringLabel(0, 0, 1, -1)
					end
				else
					SetTextComponentFormat("STRING")
					AddTextComponentString("~r~You already have some trash put it in the truck.")
					DisplayHelpTextFromStringLabel(0, 0, 1, -1)
				end
			end
		end
		if GetDistanceBetweenCoords(garbageTruckSpawn.x, garbageTruckSpawn.y, garbageTruckSpawn.z,GetEntityCoords(PlayerPedId()), true) < 5 and trashTruck then
			if IsPedInAnyVehicle(PlayerPedId()) and GetVehiclePedIsUsing(PlayerPedId()) == trashTruck then
				if totalGarbageCollected >= requiredGarbageCollected then
					SetTextComponentFormat("STRING")
					AddTextComponentString("Press ~INPUT_PICKUP~ to return your truck")
					DisplayHelpTextFromStringLabel(0, 0, 1, -1)
					if IsControlJustPressed(0,38) then
						local payme = 0
						for var=0,requiredGarbageCollected do
						   payme = payme + math.random(150, 225)
						end
						RemoveBlip(currentBlip)
						TriggerEvent('fsn_notify:displayNotification', 'Thanks for your work, you\'ve been paid: $'..payme, 'centerRight', 4000, 'info')
						TriggerEvent('fsn_bank:change:bankAdd', payme)
						currentPickup = false
						totalGarbageCollected = 0
						requiredGarbageCollected = 0
						SetEntityAsMissionEntity( trashTruck, true, true )
    				    Citizen.InvokeNative( 0xEA386986E786A54F, Citizen.PointerValueIntInitialized( trashTruck ) )
						trashTruck = false
						fsn_SetJob('Unemployed')
					end 
				else
					SetTextComponentFormat("STRING")
					AddTextComponentString("~r~Follow the waypoint to collect the garbage")
					DisplayHelpTextFromStringLabel(0, 0, 1, -1)
				end
			end
		end
		if GetDistanceBetweenCoords(garbageJobLocation.x, garbageJobLocation.y, garbageJobLocation.z,GetEntityCoords(PlayerPedId()), true) < 10 then
			DrawMarker(1,garbageJobLocation.x,garbageJobLocation.y,garbageJobLocation.z-1,0,0,0,0,0,0,1.001,1.0001,0.4001,0,155,255,175,0,0,0,0)
			if GetDistanceBetweenCoords(garbageJobLocation.x, garbageJobLocation.y, garbageJobLocation.z,GetEntityCoords(PlayerPedId()), true) < 1 then
				if not trashTruck then
					SetTextComponentFormat("STRING")
					AddTextComponentString("Press ~INPUT_PICKUP~ to start work")
					DisplayHelpTextFromStringLabel(0, 0, 1, -1)
					if IsControlJustPressed(0,38) then
						local model = 'trash'
						RequestModel(model)
						while not HasModelLoaded(model) do
							Wait(1)
						end
						local personalvehicle = CreateVehicle(model, garbageTruckSpawn.x, garbageTruckSpawn.y, garbageTruckSpawn.z, garbageTruckSpawn.h, true, false)
						TriggerEvent('fsn_fuel:update', GetVehicleNumberPlateText(personalvehicle), 100)
						trashTruck = personalvehicle
						SetModelAsNoLongerNeeded(model)
						SetVehicleOnGroundProperly(personalvehicle)
						SetVehicleHasBeenOwnedByPlayer(personalvehicle, true)
						local id = NetworkGetNetworkIdFromEntity(personalvehicle)
						SetNetworkIdCanMigrate(id, true)
						requiredGarbageCollected = math.random(6,10)
						TriggerEvent('fsn_notify:displayNotification', 'Get your van!', 'centerRight', 4000, 'info')
						TriggerEvent('fsn_cargarage:makeMine', trashTruck, GetDisplayNameFromVehicleModel(GetEntityModel(trashTruck)), GetVehicleNumberPlateText(trashTruck))
						fsn_SetJob('Trash Man')
						
						getNewWaypoint()
					end
				else
					SetTextComponentFormat("STRING")
					AddTextComponentString("~r~You have a trash truck, complete your job")
					DisplayHelpTextFromStringLabel(0, 0, 1, -1)
				end
			end
		end
	end
end)

-- if truck goes missing job
Citizen.CreateThread(function()
	while true do
		Citizen.Wait(10000)
		if trashTruck then
			if not DoesEntityExist(trashTruck) then
				TriggerEvent('fsn_notify:displayNotification', 'You were charged $1000 for destroying your garbage truck!', 'centerRight', 6000, 'error')
				RemoveBlip(currentBlip)
				TriggerEvent('fsn_bank:change:bankMinus', 1000)
				currentPickup = false
				totalGarbageCollected = 0
				requiredGarbageCollected = 0
				trashTruck = false
			end
		end
	end
end)

