diff --git a/client/cl.lua b/client/cl.lua index 6107870..018c7d6 100644 --- a/client/cl.lua +++ b/client/cl.lua @@ -2,8 +2,6 @@ local QBCore = exports['qb-core']:GetCoreObject() local PlayerWorkVans = {} local waypointCoords = vector3(-603.707, 5305.513, 70.331) local waypointCoords2 = vector(-555.627, 5314.729, 74.302) -local cameraCoords = Config.deliverySupervisorCam -local timmyCoords = Config.deliveryTaskerCam local logPropModel = GetHashKey("prop_logpile_03") local logPropEntity = nil local outlineColor = Config.outLine @@ -230,91 +228,64 @@ RegisterNetEvent('tr-lumberjack:client:returnworkvan', function() end end) - -local function startCameraTask(targetPos, targetRot, dialogMessages) - local player = PlayerPedId() - local playerPos = GetEntityCoords(player) - local cam = CreateCam("DEFAULT_SCRIPTED_CAMERA", true) - local transitionDuration = Config.camTransition * 1000 - local startTime = GetGameTimer() - local initialCamPos = vector3(playerPos.x, playerPos.y, playerPos.z + 0.5) - - SetCamCoord(cam, initialCamPos.x, initialCamPos.y, initialCamPos.z) - SetCamRot(cam, GetGameplayCamRot(0).x, GetGameplayCamRot(0).y, GetGameplayCamRot(0).z, 2) - SetCamActive(cam, true) - RenderScriptCams(true, false, 0, true, true) - - CreateThread(function() - while true do - local elapsedTime = GetGameTimer() - startTime - local progress = math.min(elapsedTime / transitionDuration, 1.0) - local newPos = CamVector(initialCamPos, targetPos, progress) - local newRot = CamVector(GetGameplayCamRot(0), targetRot, progress) - - SetCamCoord(cam, newPos.x, newPos.y, newPos.z) - SetCamRot(cam, newRot.x, newRot.y, newRot.z, 2) - - if progress >= 1.0 then - NotifyPlayer(dialogMessages[1], 'primary') - Wait(2500) - NotifyPlayer(dialogMessages[2], 'primary') - Wait(3500) - - local returnStartTime = GetGameTimer() - while true do - local returnElapsedTime = GetGameTimer() - returnStartTime - local returnProgress = math.min(returnElapsedTime / transitionDuration, 1.0) - local returnPos = CamVector(targetPos, initialCamPos, returnProgress) - local returnRot = CamVector(targetRot, GetGameplayCamRot(0), returnProgress) - - SetCamCoord(cam, returnPos.x, returnPos.y, returnPos.z) - SetCamRot(cam, returnRot.x, returnRot.y, returnRot.z, 2) - - if returnProgress >= 1.0 then - break - end - - Wait(0) - end - RenderScriptCams(false, false, 0, true, true) - DestroyCam(cam, false) - Wait(2000) - if TaskInProgress and not timmyTaskStarted then - SetNewWaypoint(-815.161, 5425.259) - NotifyPlayer(dialogMessages[3], 'success') - else - TriggerServerEvent('tr-lumberjack:server:deliverypaper') - SetNewWaypoint(1239.432, -3148.982) - NotifyPlayer(dialogMessages[3], 'success') - end - break - end - - Wait(7) - end - end) -end - RegisterNetEvent('tr-lumberjack:client:starttask', function() - if TaskInProgress then - NotifyPlayer(Lang.alreadyTasked1, 'error') - return + if IsDeliveryTruckSelected then + if TaskInProgress then + NotifyPlayer(Lang.alreadyTasked1, 'error') + return + end + exports.mt_lib:showDialogue({ + ped = ConstructionWorker1, + label = 'Larry', + speech = Lang.dialLog1, + options = { + { + id = 'lumber_accepttask', + label = Lang.dialLog2, + icon = 'hand', + close = true, + action = function() + SetNewWaypoint(-815.161, 5425.259) + end + }, + } + }) + TaskInProgress = true + Wait(5000) + NotifyPlayer(Lang.dialLog3, 'success') + Wait(5000) + NotifyPlayer(Lang.dialLog4, 'success') + else + NotifyPlayer(Lang.selectDeliveryTruck, 'error') end - TaskInProgress = true - startCameraTask(vector3(cameraCoords.x, cameraCoords.y, cameraCoords.z), vector3(0.0, 0.0, cameraCoords.w), {Lang.dialLog1, Lang.dialLog2, Lang.dialLog3}) end) RegisterNetEvent('tr-lumberjack:client:timmytask', function() - if not TrailerFull then - NotifyPlayer(Lang.timmyTask, 'error') - return - end - if timmyTaskStarted then - NotifyPlayer(Lang.timmyTask, 'error') - return - end - timmyTaskStarted = true - startCameraTask(vector3(Config.deliveryTaskerCam.x, Config.deliveryTaskerCam.y, Config.deliveryTaskerCam.z), vector3(0.0, 0.0, Config.deliveryTaskerCam.w), {Lang.timmyDialLog1, Lang.timmyDialLog2, Lang.timmyDialLog3}) + exports.mt_lib:showDialogue({ + ped = ConstructionWorker2, + label = 'Timmy', + speech = Lang.timmyTask1, + options = { + { + id = 'lumber_acceptdelivery', + label = Lang.timmyTask2, + icon = 'hand', + close = true, + action = function() + if TrailerFull then + NotifyPlayer(Lang.timmyTask, 'error') + return + end + if timmyTaskStarted then + NotifyPlayer(Lang.timmyTask, 'error') + return + end + TriggerServerEvent('tr-lumberjack:server:deliverypaper') + SetNewWaypoint(1239.432, -3148.982) + end + }, + } + }) end) function CamVector(startVec, endVec, t) diff --git a/client/menu.lua b/client/menu.lua index e8aaafd..a47e2f5 100644 --- a/client/menu.lua +++ b/client/menu.lua @@ -33,21 +33,6 @@ if Config.menu == "qbcore" then }, }) end) - RegisterNetEvent('tr-lumberjack:client:deliverysuper', function() - if IsDeliveryTruckSelected then - exports['qb-menu']:openMenu({ - { - header = Lang.delivery1, - icon = 'fa-solid fa-trailer', - params = { - event = 'tr-lumberjack:client:starttask', - } - } - }) - else - NotifyPlayer(Lang.selectDeliveryTruck, 'error') - end - end) RegisterNetEvent('tr-lumberjack:client:trailerInteract', function() exports['qb-menu']:openMenu({ { @@ -181,23 +166,6 @@ elseif Config.menu == "ox" then }) lib.showContext('lumberjack_depo') end) - RegisterNetEvent('tr-lumberjack:client:deliverysuper', function() - if IsDeliveryTruckSelected then - lib.registerContext({ - id = 'lumberjack_super', - title = Lang.interact2, - options = { - { - title = Lang.delivery1, - event = 'tr-lumberjack:client:starttask', - }, - } - }) - lib.showContext('lumberjack_super') - else - NotifyPlayer(Lang.selectDeliveryTruck, 'error') - end - end) RegisterNetEvent('tr-lumberjack:client:trailerInteract', function() lib.registerContext({ id = 'lumber_trailer', diff --git a/client/peds.lua b/client/peds.lua index c44a90c..5b247a7 100644 --- a/client/peds.lua +++ b/client/peds.lua @@ -53,8 +53,8 @@ end CreateThread(function() Wait(1000) local lumberjack1 = CreateLumberPed(TRClassic, false) - local constructionWorker1 = CreateLumberPed(classicSupervisorCoords, true) - local constructionWorker2 = CreateLumberPed(ClassicTR, true) + ConstructionWorker1 = CreateLumberPed(classicSupervisorCoords, true) + ConstructionWorker2 = CreateLumberPed(ClassicTR, true) local lumberjack2 = CreateLumberPed(bingBong, false) local lumberjack3 = CreateLumberPed(fuckYourLife, false) diff --git a/client/target.lua b/client/target.lua index 332a80c..fad159b 100644 --- a/client/target.lua +++ b/client/target.lua @@ -21,7 +21,7 @@ local boxZones = { name = 'zone2', label = Lang.interact2, icon = 'fa-solid fa-cogs', - event = 'tr-lumberjack:client:deliverysuper' + event = 'tr-lumberjack:client:starttask' }, { -- Delivery Tasker diff --git a/fxmanifest.lua b/fxmanifest.lua index 1d1dc97..35a0ea3 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -3,7 +3,7 @@ game 'gta5' author 'TRClassic' description 'LumberJack Job For QB-Core / Ox' -version '2.0.2' +version '2.0.3' shared_scripts { 'lang/en.lua', diff --git a/lang/en.lua b/lang/en.lua index e8df06d..d9ca5d3 100644 --- a/lang/en.lua +++ b/lang/en.lua @@ -27,13 +27,13 @@ Lang = { depoInvoice = "Contact", depoMessage = "", -- Not used -- NPC - dialLog1 = "Larry: Hello! I have a task for you.", - dialLog2 = "Larry: Please collect some logs at the waypoint we added to your GPS!", + dialLog1 = "Hello! I have a task for you.", + dialLog2 = "Accept Task", dialLog3 = "Task: Go to the marked location to collect logs.", dialLog4 = "Task: Drive the truck with the Flatbed to load logs onto it", - timmyDialLog1 = "Timmy: Got the paper work your trailer is put together", - timmyDialLog2 = "Timmy: I will be sending you a ping of a delivery point", - timmyDialLog3 = "Ping has been applied to your GPS", + timmyTask1 = "Grab A Delivery Form", + timmyTask2 = "Request Delivery", + timmyDialLog1 = "Ping has been applied to your GPS", -- Task Areas task1 = "Collect Logs", task2 = "Loaded log onto the trailer!", @@ -93,6 +93,7 @@ Lang = { tooFarFromTasker = "To Far From Timmy", alreadyHaveDeliveryPaper = "Already Have Delivery Paper", tooFarFromDepo = "To Far From Depo", + deliveryPaperFailed = "Couldn't Hand Over A Delivery Paper", -- Progress bar pickingLog = "Getting log ready for transport", loadingTrailer = "Loading Log onto trailer", @@ -105,5 +106,6 @@ Lang = { -- Debug debug1 = "Ground log prop deleted upon re-picking the log.", debug2 = "Ground log prop deleted after 5 minutes.", + invalidPlayer = "Invalid", } \ No newline at end of file diff --git a/server/sv.lua b/server/sv.lua index 26cb5f9..43997a3 100644 --- a/server/sv.lua +++ b/server/sv.lua @@ -24,16 +24,16 @@ RegisterServerEvent('tr-lumberjack:server:returnworkvan', function() if Player then local playerCoords = GetEntityCoords(GetPlayerPed(source)) - local depoCoords = Config.lumberDepo + local depoCoords = vector3(Config.lumberDepo.x, Config.lumberDepo.y, Config.lumberDepo.z) if #(playerCoords - depoCoords) > 10.0 then notifyPlayer(source, Lang.tooFarFromDepo, 'error') return end if exports.ox_inventory:AddItem(source, 'cash', Config.returnPrice) then - notifyPlayer(source, Lang.workVanReturned, 'success') + notifyPlayer(source, Lang.storedVehicle, 'success') else - notifyPlayer(source, Lang.returnVanFailed, 'error') + notifyPlayer(source, Lang.incorrectVehicle, 'error') end else notifyPlayer(source, Lang.invalidPlayer, 'error') @@ -70,18 +70,20 @@ RegisterServerEvent('tr-lumberjack:server:deliverypaper', function() if Player then local playerCoords = GetEntityCoords(GetPlayerPed(source)) - local taskerCoords = Config.deliveryTasker + local taskerCoords = vector3(Config.deliveryTasker.x, Config.deliveryTasker.y, Config.deliveryTasker.z) + if #(playerCoords - taskerCoords) > 10.0 then notifyPlayer(source, Lang.tooFarFromTasker, 'error') return end + if exports.ox_inventory:Search(source, 'count', 'tr_deliverypaper') > 0 then notifyPlayer(source, Lang.alreadyHaveDeliveryPaper, 'error') return end if exports.ox_inventory:AddItem(source, 'tr_deliverypaper', 1) then - notifyPlayer(source, Lang.receivedDeliveryPaper, 'success') + notifyPlayer(source, Lang.timmyDialLog1, 'success') else notifyPlayer(source, Lang.deliveryPaperFailed, 'error') end @@ -138,7 +140,6 @@ end) RegisterServerEvent('tr-lumberjack:server:choptree', function() local source = source - -- Because you are going to be able to carry till your inventory is full (Don't ask why because Im stupid alright) if exports.ox_inventory:CanCarryItem(source, 'tr_choppedlog', 1) then if exports.ox_inventory:AddItem(source, 'tr_choppedlog', 1) then