qbcore-framework / qb-cityhall

City Hall Script For QB-Core
GNU General Public License v3.0
25 stars 186 forks source link

feat: Properly implement AddJob export #81

Closed tom-osborne closed 1 year ago

tom-osborne commented 1 year ago

Describe Pull request This allows the AddJob export (previously added in #77) to show on the UI as a selectable option after being added.

Usage example on server side in a new resource that is adding the job: Note: This will only add the job to the qb-cityhall menu. You will still need to add the job into QBShared.Jobs

RegisterNetEvent("onResourceStart", function(resource)
   if resource == GetCurrentResourceName() then
      Wait(100)
      local job = "Construction"
      local jobName = "Construction Worker"
      exports["qb-cityhall"]:AddCityJob(job, jobName)
   end
end)

This can also be added to the QBCore.Functions.AddJob function allowing a resource to add the job to shared/jobs table and cityhall in one go, making the usage example as follows:

RegisterNetEvent("onResourceStart", function(resource)
   if resource == GetCurrentResourceName() then
      Wait(100)
      local job = "Construction"
      local jobName = "Construction Worker"
      QBCore.Functions.AddJob(jobName, job)
   end
end)

See https://github.com/qbcore-framework/qb-core/pull/870

Questions (please complete the following information):