Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ESX = exports["es_extended"]:getSharedObject()
- local checked = false
- local currentlyWorking = false
- local generatedHouse = 0
- local taskBlip = nil
- local wCoords = nil
- local garageOpened = false
- RegisterNetEvent('esx:playerLoaded')
- AddEventHandler('esx:playerLoaded', function(xPlayer)
- ESX.PlayerData = xPlayer
- end)
- RegisterNetEvent('esx:setJob')
- AddEventHandler('esx:setJob', function(job)
- ESX.PlayerData.job = job
- checked = false
- end)
- while true do
- Citizen.Wait(0)
- local playerPed = PlayerPedId()
- local coords = GetEntityCoords(playerPed)
- local currentZone = nil
- if not checked then
- DisplayBlip()
- checked = true
- end
- if ESX.PlayerData.job and ESX.PlayerData.job.name == 'ubereats' then
- if not currentlyWorking then
- if #(coords - Config.Points.Service) < 10 then
- 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)
- if #(coords - Config.Points.Service) < 2 then
- HelpText("Press ~INPUT_CONTEXT~ to work")
- if IsControlJustReleased(0, 38) then
- generatedHouse = math.random(1, #Config.Points.Houses)
- CreateTaskBlip(Config.Points.Houses[generatedHouse])
- SetNewWaypoint(Config.Points.Houses[generatedHouse].x, Config.Points.Houses[generatedHouse].y)
- wCoords = coords
- NotificationText("New delivery available, check your gps.")
- currentlyWorking = true
- end
- end
- end
- else
- local dist = #(coords - Config.Points.Houses[generatedHouse])
- if dist < 20 then
- 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)
- if dist < 1 then
- HelpText("Press ~INPUT_CONTEXT~ to deliver")
- if IsControlJustReleased(0, 38) then
- if not IsPedInAnyVehicle(playerPed, true) then
- StartTask(#(wCoords - Config.Points.Houses[generatedHouse]))
- generatedHouse = math.random(1, #Config.Points.Houses)
- CreateTaskBlip(Config.Points.Houses[generatedHouse])
- SetNewWaypoint(Config.Points.Houses[generatedHouse].x, Config.Points.Houses[generatedHouse].y)
- NotificationText("New delivery available, check your gps.")
- wCoords = coords
- else
- NotificationText("Please get out of your vehicle!")
- end
- end
- end
- end
- if #(coords - Config.Points.Service) < 10 then
- 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)
- if #(coords - Config.Points.Service) < 2 then
- HelpText("Press ~INPUT_CONTEXT~ to stop work")
- if IsControlJustReleased(0, 38) then
- if taskBlip ~= nil then
- RemoveBlip(taskBlip)
- end
- currentlyWorking = false
- end
- end
- end
- if #(coords - Config.Points.Garage) < 10 then
- 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)
- if #(coords - Config.Points.Garage) < 2 then
- HelpText("Press ~INPUT_CONTEXT~ to open the garage")
- if IsControlJustReleased(0, 38) then
- garageOpened = true
- OpenVehicleSpawnerMenu()
- end
- end
- end
- if #(coords - Config.Points.DeleteVeh) < 10 and IsPedInAnyVehicle(playerPed) then
- 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)
- if #(coords - Config.Points.DeleteVeh) < 4 then
- HelpText("Press ~INPUT_CONTEXT~ to delete the vehicle")
- if IsControlJustReleased(0, 38) then
- local vehicle = GetVehiclePedIsIn(playerPed, false)
- if GetVehicleNumberPlateText(vehicle) == "UBEREATS" then
- DeleteVehicle(vehicle)
- else
- NotificationText("This vehicle is not from the company!")
- end
- end
- end
- end
- end
- else
- Wait(500)
- end
- end
- end
- end)
- RegisterNetEvent("cubereats:notif")
- AddEventHandler("cubereats:notif", function(txt)
- NotificationText(txt)
- end)
- function StartTask(distance)
- local playerPed = PlayerPedId()
- local randomTime = math.random(Config.WaitTime.min, Config.WaitTime.max)
- local breaker = false
- if Config.RProgress then
- exports.rprogress:Custom({
- Duration = randomTime,
- Stroke = 15,
- DisableControls = {
- Mouse = true, -- enable / disable camera movement
- Player = true, -- enable / disable player movement
- Vehicle = true -- enable / disable vehicle movement / usage
- },
- })
- else
- CreateThread(function()
- while not breaker do
- Wait(0)
- DisableAllControlActions(0)
- DisableAllControlActions(1)
- DisableAllControlActions(2)
- DisableAllControlActions(3)
- end
- end)
- end
- Wait(randomTime)
- breaker = true
- TriggerServerEvent("cubereats:taskDone", distance)
- end
- function OpenVehicleSpawnerMenu()
- ESX.UI.Menu.CloseAll()
- CreateThread(function()
- while garageOpened do
- Wait(100)
- local coords = GetEntityCoords(PlayerPedId())
- if #(coords - Config.Points.Garage) > 3 then
- ESX.UI.Menu.CloseAll()
- end
- end
- end)
- ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_spawner', {
- title = "Garage",
- align = 'top-left',
- elements = Config.Vehicles.Garage
- }, function(data, menu)
- menu.close()
- garageOpened = false
- TriggerServerEvent("cubereats:pay", data.current.price)
- 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)
- local playerPed = PlayerPedId()
- Config.Vehicles.Customization.Colours(vehicle)
- Config.Vehicles.Customization.ExtraColours(vehicle)
- Config.Vehicles.Customization.Plate(vehicle)
- TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
- end)
- end, function(data, menu)
- garageOpened = false
- menu.close()
- end)
- end
- function HelpText(text)
- BeginTextCommandDisplayHelp('STRING')
- AddTextComponentSubstringPlayerName(text)
- EndTextCommandDisplayHelp(0, false, true, -1)
- end
- function NotificationText(text)
- SetNotificationTextEntry('STRING')
- AddTextComponentSubstringPlayerName(text)
- DrawNotification(false, true)
- end
- function DisplayBlip()
- local blip = AddBlipForCoord(Config.Points.Service)
- SetBlipSprite(blip, 56)
- SetBlipDisplay(blip, 4)
- SetBlipScale(blip, 0.8)
- SetBlipColour(blip, 69)
- SetBlipAsShortRange(blip, true)
- BeginTextCommandSetBlipName('STRING')
- AddTextComponentSubstringPlayerName("Uber Eats")
- EndTextCommandSetBlipName(blip)
- end
- function CreateTaskBlip(coords)
- if taskBlip ~= nil then
- RemoveBlip(taskBlip)
- end
- taskBlip = AddBlipForCoord(coords)
- SetBlipSprite(taskBlip, 161)
- SetBlipDisplay(taskBlip, 4)
- SetBlipScale(taskBlip, 0.3)
- SetBlipColour(taskBlip, 69)
- SetBlipAsShortRange(taskBlip, true)
- BeginTextCommandSetBlipName('STRING')
- AddTextComponentSubstringPlayerName("Uber Eats : Delivery")
- EndTextCommandSetBlipName(taskBlip)
- end
Advertisement
Add Comment
Please, Sign In to add comment