Guest User

Untitled

a guest
Dec 28th, 2023
823
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.02 KB | None | 0 0
  1. ESX = exports["es_extended"]:getSharedObject()
  2. local checked = false
  3. local currentlyWorking = false
  4. local generatedHouse = 0
  5. local taskBlip = nil
  6. local wCoords = nil
  7. local garageOpened = false
  8.  
  9. RegisterNetEvent('esx:playerLoaded')
  10. AddEventHandler('esx:playerLoaded', function(xPlayer)
  11. ESX.PlayerData = xPlayer
  12. end)
  13.  
  14. RegisterNetEvent('esx:setJob')
  15. AddEventHandler('esx:setJob', function(job)
  16. ESX.PlayerData.job = job
  17. checked = false
  18. end)
  19.  
  20. while true do
  21. Citizen.Wait(0)
  22.  
  23. local playerPed = PlayerPedId()
  24. local coords = GetEntityCoords(playerPed)
  25. local currentZone = nil
  26.  
  27. if not checked then
  28. DisplayBlip()
  29. checked = true
  30. end
  31.  
  32. if ESX.PlayerData.job and ESX.PlayerData.job.name == 'ubereats' then
  33.  
  34. if not currentlyWorking then
  35. if #(coords - Config.Points.Service) < 10 then
  36. DrawMarker(6, Config.Points.Service.x, Config.Points.Service.y, Config.Points.Service.z - 0.95, 0.0, 0.0, 90.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 50, 200, 50, 100, false, false, 2, nil, nil, false)
  37. if #(coords - Config.Points.Service) < 2 then
  38. HelpText("Press ~INPUT_CONTEXT~ to work")
  39. if IsControlJustReleased(0, 38) then
  40. generatedHouse = math.random(1, #Config.Points.Houses)
  41. CreateTaskBlip(Config.Points.Houses[generatedHouse])
  42. SetNewWaypoint(Config.Points.Houses[generatedHouse].x, Config.Points.Houses[generatedHouse].y)
  43. wCoords = coords
  44. NotificationText("New delivery available, check your gps.")
  45. currentlyWorking = true
  46. end
  47. end
  48. end
  49. else
  50. local dist = #(coords - Config.Points.Houses[generatedHouse])
  51. if dist < 20 then
  52. DrawMarker(20, Config.Points.Houses[generatedHouse], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 70, 255, 75, 200, true, false, false, true)
  53. if dist < 1 then
  54. HelpText("Press ~INPUT_CONTEXT~ to deliver")
  55. if IsControlJustReleased(0, 38) then
  56. if not IsPedInAnyVehicle(playerPed, true) then
  57. StartTask(#(wCoords - Config.Points.Houses[generatedHouse]))
  58.  
  59. generatedHouse = math.random(1, #Config.Points.Houses)
  60. CreateTaskBlip(Config.Points.Houses[generatedHouse])
  61. SetNewWaypoint(Config.Points.Houses[generatedHouse].x, Config.Points.Houses[generatedHouse].y)
  62. NotificationText("New delivery available, check your gps.")
  63. wCoords = coords
  64. else
  65. NotificationText("Please get out of your vehicle!")
  66. end
  67. end
  68. end
  69. end
  70.  
  71. if #(coords - Config.Points.Service) < 10 then
  72. DrawMarker(6, Config.Points.Service.x, Config.Points.Service.y, Config.Points.Service.z - 0.95, 0.0, 0.0, 90.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 200, 50, 50, 100, false, false, 2, nil, nil, false)
  73. if #(coords - Config.Points.Service) < 2 then
  74. HelpText("Press ~INPUT_CONTEXT~ to stop work")
  75. if IsControlJustReleased(0, 38) then
  76. if taskBlip ~= nil then
  77. RemoveBlip(taskBlip)
  78. end
  79. currentlyWorking = false
  80. end
  81. end
  82. end
  83.  
  84. if #(coords - Config.Points.Garage) < 10 then
  85. DrawMarker(6, Config.Points.Garage.x, Config.Points.Garage.y, Config.Points.Garage.z - 0.95, 0.0, 0.0, 90.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 50, 200, 200, 100, false, false, 2, nil, nil, false)
  86. if #(coords - Config.Points.Garage) < 2 then
  87. HelpText("Press ~INPUT_CONTEXT~ to open the garage")
  88. if IsControlJustReleased(0, 38) then
  89. garageOpened = true
  90. OpenVehicleSpawnerMenu()
  91. end
  92. end
  93. end
  94.  
  95. if #(coords - Config.Points.DeleteVeh) < 10 and IsPedInAnyVehicle(playerPed) then
  96. DrawMarker(6, Config.Points.DeleteVeh.x, Config.Points.DeleteVeh.y, Config.Points.DeleteVeh.z - 0.95, 0.0, 0.0, 90.0, 0.0, 0.0, 0.0, 2.0, 2.0, 2.0, 200, 50, 50, 100, false, false, 2, nil, nil, false)
  97. if #(coords - Config.Points.DeleteVeh) < 4 then
  98. HelpText("Press ~INPUT_CONTEXT~ to delete the vehicle")
  99. if IsControlJustReleased(0, 38) then
  100. local vehicle = GetVehiclePedIsIn(playerPed, false)
  101. if GetVehicleNumberPlateText(vehicle) == "UBEREATS" then
  102. DeleteVehicle(vehicle)
  103. else
  104. NotificationText("This vehicle is not from the company!")
  105. end
  106. end
  107. end
  108. end
  109. end
  110. else
  111. Wait(500)
  112. end
  113. end
  114. end
  115. end)
  116.  
  117. RegisterNetEvent("cubereats:notif")
  118. AddEventHandler("cubereats:notif", function(txt)
  119. NotificationText(txt)
  120. end)
  121.  
  122. function StartTask(distance)
  123. local playerPed = PlayerPedId()
  124. local randomTime = math.random(Config.WaitTime.min, Config.WaitTime.max)
  125. local breaker = false
  126. if Config.RProgress then
  127. exports.rprogress:Custom({
  128. Duration = randomTime,
  129. Stroke = 15,
  130. DisableControls = {
  131. Mouse = true, -- enable / disable camera movement
  132. Player = true, -- enable / disable player movement
  133. Vehicle = true -- enable / disable vehicle movement / usage
  134. },
  135. })
  136. else
  137. CreateThread(function()
  138. while not breaker do
  139. Wait(0)
  140. DisableAllControlActions(0)
  141. DisableAllControlActions(1)
  142. DisableAllControlActions(2)
  143. DisableAllControlActions(3)
  144. end
  145. end)
  146. end
  147.  
  148. Wait(randomTime)
  149. breaker = true
  150. TriggerServerEvent("cubereats:taskDone", distance)
  151. end
  152.  
  153. function OpenVehicleSpawnerMenu()
  154. ESX.UI.Menu.CloseAll()
  155.  
  156. CreateThread(function()
  157. while garageOpened do
  158. Wait(100)
  159. local coords = GetEntityCoords(PlayerPedId())
  160. if #(coords - Config.Points.Garage) > 3 then
  161. ESX.UI.Menu.CloseAll()
  162. end
  163. end
  164. end)
  165.  
  166. ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_spawner', {
  167. title = "Garage",
  168. align = 'top-left',
  169. elements = Config.Vehicles.Garage
  170. }, function(data, menu)
  171. menu.close()
  172. garageOpened = false
  173. TriggerServerEvent("cubereats:pay", data.current.price)
  174.  
  175. ESX.Game.SpawnVehicle(data.current.vehicle, vector3(Config.Points.GarageSpawn.x, Config.Points.GarageSpawn.y, Config.Points.GarageSpawn.z), Config.Points.GarageSpawn.h, function(vehicle)
  176. local playerPed = PlayerPedId()
  177. Config.Vehicles.Customization.Colours(vehicle)
  178. Config.Vehicles.Customization.ExtraColours(vehicle)
  179. Config.Vehicles.Customization.Plate(vehicle)
  180. TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
  181. end)
  182. end, function(data, menu)
  183. garageOpened = false
  184. menu.close()
  185. end)
  186. end
  187.  
  188. function HelpText(text)
  189. BeginTextCommandDisplayHelp('STRING')
  190. AddTextComponentSubstringPlayerName(text)
  191. EndTextCommandDisplayHelp(0, false, true, -1)
  192. end
  193.  
  194. function NotificationText(text)
  195. SetNotificationTextEntry('STRING')
  196. AddTextComponentSubstringPlayerName(text)
  197. DrawNotification(false, true)
  198. end
  199.  
  200. function DisplayBlip()
  201. local blip = AddBlipForCoord(Config.Points.Service)
  202.  
  203. SetBlipSprite(blip, 56)
  204. SetBlipDisplay(blip, 4)
  205. SetBlipScale(blip, 0.8)
  206. SetBlipColour(blip, 69)
  207. SetBlipAsShortRange(blip, true)
  208.  
  209. BeginTextCommandSetBlipName('STRING')
  210. AddTextComponentSubstringPlayerName("Uber Eats")
  211. EndTextCommandSetBlipName(blip)
  212. end
  213.  
  214. function CreateTaskBlip(coords)
  215. if taskBlip ~= nil then
  216. RemoveBlip(taskBlip)
  217. end
  218.  
  219. taskBlip = AddBlipForCoord(coords)
  220.  
  221. SetBlipSprite(taskBlip, 161)
  222. SetBlipDisplay(taskBlip, 4)
  223. SetBlipScale(taskBlip, 0.3)
  224. SetBlipColour(taskBlip, 69)
  225. SetBlipAsShortRange(taskBlip, true)
  226.  
  227. BeginTextCommandSetBlipName('STRING')
  228. AddTextComponentSubstringPlayerName("Uber Eats : Delivery")
  229. EndTextCommandSetBlipName(taskBlip)
  230. end
Advertisement
Add Comment
Please, Sign In to add comment