From dc83bfc96ff9c4f1b961864a19d16571c7a8244d Mon Sep 17 00:00:00 2001 From: DonHulieo <96005229+DonHulieo@users.noreply.github.com> Date: Mon, 18 Sep 2023 14:42:36 +1000 Subject: [PATCH] Fix Job Requirement Config Option Script wasn't properly populating the job into the shared object, or into the cityhall. Newest update now allows for the auto-population of both on startup. --- README.md | 29 ++++++++++++++++++++++++++++- client/main.lua | 7 +++++-- config.lua | 6 ++++-- fxmanifest.lua | 2 +- server/main.lua | 7 ++++++- 5 files changed, 44 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 4cea503..d89b6b1 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Warehousing script for QBCore - Can be used for a specific job (set in the config) or for anyone as an activity - Can be configured for multiple warehouses (set in the config) ~ Supports 3 warehouses by default and Ultrunz's Warehouse - Earn Bonus Money for completing the job without damaging the pallets -- A percantage of money earned through deliveries is sent to the business society +- A percentage of money earned through deliveries is sent to the business society ## Installation @@ -27,6 +27,33 @@ Warehousing script for QBCore - **Note:** If RequiresJob is set to true, the job can be set in the config, if set to false, the job is not required. +### When using the Job Requirement + +- You don't need to add the job to your qb-core config, as it will be added automatically +- Find the following code in qb-cityhall/server/main.lua, in the 'qb-cityhall:server:ApplyJob' Event + +```lua + if QBCore.Shared.QBJobsStatus then + exports["qb-jobs"]:submitApplication(data, "Jobs") + else + local JobInfo = QBCore.Shared.Jobs[job] + Player.Functions.SetJob(data.job, 0) + TriggerClientEvent('QBCore:Notify', data.src, Lang:t('info.new_job', { job = JobInfo.label })) + end +``` + +- Replace it with the following code + +```lua + if QBCore.Shared.QBJobsStatus then + exports["qb-jobs"]:submitApplication(data, "Jobs") + else + local JobInfo = QBCore.Shared.Jobs[job] or availableJobs[job] + Player.Functions.SetJob(data.job, 0) + TriggerClientEvent('QBCore:Notify', data.src, Lang:t('info.new_job', { job = JobInfo.label })) + end +``` + ## Job Locations - For the Warehouse used in the preview: diff --git a/client/main.lua b/client/main.lua index 04c5312..010cea1 100644 --- a/client/main.lua +++ b/client/main.lua @@ -171,7 +171,6 @@ local function getUsersCurrentWarehouse() for current = 1, #Config.Locations do if Config.Locations[current].inUse and Config.Locations[current].user == identifier then return current end end - return nil end ---@param location number @@ -535,7 +534,11 @@ end) RegisterNetEvent('QBCore:Client:OnJobUpdate', function(JobInfo) for id, warehouse in pairs(Config.Locations) do if Config.RequiresJob then - if JobInfo.name == Config.Job then + local function getK() + for k in pairs(Config.Job) do return k end + end + local tableName = getK() + if JobInfo.name == tableName then PlayerData.job = JobInfo if Config.Blips then createBlip(warehouse['Start'].coords, warehouse['Blips'].label, warehouse['Blips'].sprite, warehouse['Blips'].color, warehouse['Blips'].scale) diff --git a/config.lua b/config.lua index b52fc9a..239993b 100644 --- a/config.lua +++ b/config.lua @@ -15,7 +15,8 @@ Config.PalletMarkers = { -- Pallet markers | https://docs.fivem.net/docs/game-re Config.FuelSystem = 'LegacyFuel' -- Fuel system your server is using -Config.RequiresJob = false -- Enable if you want to require a job to an order +Config.RequiresJob = true -- Enable if you want to require a job to an order +Config.IsManaged = true -- Enable if you want to use the QB-Cityhall job management system Config.Job = { ['logistics'] = { label = 'Warehouse Logistics', @@ -36,7 +37,8 @@ Config.Job = { }, ['3'] = { name = 'Owner', - pay = 750 + pay = 750, + isboss = true } } } diff --git a/fxmanifest.lua b/fxmanifest.lua index 632995a..79c5e1f 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -3,7 +3,7 @@ game 'gta5' author 'DonHulieo' description 'Warehousing Job for QBCore' -version '1.1.9' +version '1.2.0' shared_scripts {'config.lua'} diff --git a/server/main.lua b/server/main.lua index ddb1117..36e9645 100644 --- a/server/main.lua +++ b/server/main.lua @@ -66,7 +66,12 @@ QBCore.Functions.CreateCallback('don-forklift:server:GetLocations', function(sou end) if Config.RequiresJob then - QBCore.Functions.AddJobs(Config.Job['logistics']) + local function getK() + for k in pairs(Config.Job) do return k end + end + local tableName = getK() + QBCore.Functions.AddJob(tableName, Config.Job[tableName]) + exports['qb-cityhall']:AddCityJob(tableName, {label = Config.Job[tableName].label, isManaged = Config.IsManaged}) end -------------------------------- THREADS --------------------------------