Hello everyone,
i’m trying to create a QB script where i need to create jobs directly from the resource, i used QB Shared Exports for achieve this job, but i have a problem, the job is created and i can retrieve it Server Side, but i cannot Client Side, client side i see only jobs from the shared/jobs.lua file, someone can help me?
This is the code:
Server:
QBCore = exports['qb-core']:GetCoreObject()
RegisterNetEvent('QBCore:Server:UpdateObject', function()
if source ~= '' then return false end
QBCore = exports['qb-core']:GetCoreObject()
end)
-- JOB --
exports['qb-core']:AddJob(
'test_job,
{
label = 'Test Job',
defaultDuty = true,
offDutyPay = false,
grades = {
['0'] = {
name = "TestName1",
payment = 50
},
['1'] = {
name = "TestName2",
payment = 100
isboss = true
},
}
}
)
-- JUST FOR TESTING ---
QBCore.Functions.CreateCallback('kaos:test', function(source, cb)
cb(QBCore.Shared.Jobs)
end)
Client:
local QBCore = exports['qb-core']:GetCoreObject()
function dump(o)
if type(o) == 'table' then
local s = '{ '
for k,v in pairs(o) do
if type(k) ~= 'number' then k = '"'..k..'"' end
s = s .. '['..k..'] = ' .. dump(v) .. ','
end
return s .. '} '
else
return tostring(o)
end
end
RegisterNetEvent('QBCore:Client:UpdateObject', function()
QBCore = exports['qb-core']:GetCoreObject()
end)
-- JUST TESTING --
QBCore.Functions.TriggerCallback('kaos:test', function(result)
print('ServerSide: ' .. result)
print('ClientSide: ' .. dump(QBCore.Shared.Jobs))
end, 'par')
When i print QBCore.Shared.Jobs server side i see all of them (even the Test Job) but when i print them client side i see only the ones in shared/jobs.lua file and this off course give me errors when i call qb-management client side (bossmenu) and stuff like this.
Someone know how fix it or is just a bug?
Thanks in advance