Shared Exports | QBCore Documentation (2024)

Learn how to use exports to update the shared dynamically!

Function or EventScopeDescriptionreturns

exports['qb-core']:AddItem(itemName, item)

Server

Accepts an item name and item object - will add new entry to QBCore.Shared.Items

boolean, string

exports['qb-core']:AddJob(jobName, job)

Server

Accepts an job name and job object - will add new entry to QBCore.Shared.Jobs

boolean, string

exports['qb-core']:AddGang(gangName, gang)

Server

Accepts an gang name and gang object - will add new entry to QBCore.Shared.Gangs

boolean, string

exports['qb-core']:AddItems(items)

Server

Accepts a table or array - will loop through the table and add new entries to QBCore.Shared.Items

boolean, string, errorItem

exports['qb-core']:AddJobs(jobs)

Server

Accepts a table or array - will loop through the table and add new entries to QBCore.Shared.Jobs

boolean, string, errorItem

exports['qb-core']:AddGangs(gangs)

Server

Accepts a table or array - will loop through the table and add new entries to QBCore.Shared.Gangs

boolean, string, errorItem

QBCore.Functions.AddItem(itemName, item)

Server

Accepts an item name and item object - will add new entry to QBCore.Shared.Items

boolean, string

QBCore.Functions.AddJob(jobName, Job)

Server

Accepts an job name and job object - will add new entry to QBCore.Shared.Jobs

boolean, string

QBCore.Functions.AddGang(gangName, gang)

Server

Accepts an gang name and gang object - will add new entry to QBCore.Shared.Gangs

boolean, string

QBCore.Functions.AddItems(items)

Server

Accepts a table or array - will loop through the table and add new entries to QBCore.Shared.Items

boolean, string, errorItem

QBCore.Functions.AddJobs(jobs)

Server

Accepts a table or array - will loop through the table and add new entries to QBCore.Shared.Jobs

boolean, string, errorItem

QBCore.Functions.AddGangs(gangs)

Server

Accepts a table or array - will loop through the table and add new entries to QBCore.Shared.Gangs

boolean, string, errorItem

TriggerServerEvent('QBCore:Sever:UpdateObject')

Server

Accepts nothing - used to update the core object (PLEASE USE THE BELOW EXAMPLE)

none

TriggerClientEvent('QBCore:Client:UpdateObject')

Client

Accepts nothing - used to update the core object (PLEASE USE THE BELOW EXAMPLE)

none

Import Jobs

  • This method allows for any resource to insert job data into the shared file for the core. That means that you can make a resource, and on load, make those jobs available for use. This can be accomplished through one the ways shown below. Utilizing the function requires importing the core but using the export does not

Read over and learn the Shared structure before attempting to use these

You must add this code to the client-side file of your resource when using these if you need the core object!

RegisterNetEvent('QBCore:Client:UpdateObject', function()QBCore = exports['qb-core']:GetCoreObject()end)

You must add this code to the server-side file of your resource when using these if you need the core object!

RegisterNetEvent('QBCore:Server:UpdateObject', function()if source ~= '' then return false endQBCore = exports['qb-core']:GetCoreObject()end)

QBCore.Functions.AddJob

QBCore.Functions.AddJob(jobName --[[string]], job --[[table]])-- ExampleQBCore.Functions.AddJob('unemployed', { label = 'Civilian', defaultDuty = true, offDutyPay = false, grades = { ['0'] = { name = 'Freelancer', payment = 10 } }})

exports['qb-core']:AddJob

exports['qb-core']:AddJob(jobName --[[string]], job --[[table]])-- Exampleexports['qb-core']:AddJob('unemployed', { label = 'Civilian', defaultDuty = true, offDutyPay = false, grades = { ['0'] = { name = 'Freelancer', payment = 10 } }})

QBCore.Functions.AddJobs

QBCore.Functions.AddJobs(jobs --[[table]])-- ExampleQBCore.Functions.AddJobs({ ['unemployed'] = { label = 'Civilian', defaultDuty = true, offDutyPay = false, grades = { ['0'] = { name = 'Freelancer', payment = 10 } }, ['trucker'] = {label = 'Trucker',defaultDuty = true,offDutyPay = false,grades = { ['0'] = { name = 'Driver', payment = 50 } }})

exports['qb-core']:AddJobs

exports['qb-core']:AddJobs(jobs --[[table]])-- Exampleexports['qb-core']:AddJobs({ ['unemployed'] = { label = 'Civilian', defaultDuty = true, offDutyPay = false, grades = { ['0'] = { name = 'Freelancer', payment = 10 } }, ['trucker'] = {label = 'Trucker',defaultDuty = true,offDutyPay = false,grades = { ['0'] = { name = 'Driver', payment = 50 } }})

Import Gangs

  • This method allows for any resource to insert gang data into the shared file for the core. That means that you can make a resource, and on load, make those gangs available for use. This can be accomplished through one the ways shown below. Utilizing the function requires importing the core but using the export does not

QBCore.Functions.AddGang

QBCore.Functions.AddGang(gangName --[[string]], gang --[[table]])-- ExampleQBCore.Functions.AddGang('azteca', { label = 'Azteca', grades = { ['0'] = { name = 'Recruit' } }})

exports['qb-core']:AddGang

exports['qb-core']:AddGang(gangName --[[string]], gang --[[table]])-- Exampleexports['qb-core']:AddGang('azteca', { label = 'Azteca', grades = { ['0'] = { name = 'Recruit' } }})

QBCore.Functions.AddGangs

QBCore.Functions.AddGangs(gangs --[[table]])-- ExampleQBCore.Functions.AddGangs({ ['lostmc'] = { label = 'Lost MC', grades = { ['0'] = { name = 'Recruit' } } }, ['ballas'] = { label = 'Ballas', grades = { ['0'] = { name = 'Recruit' } } }})

exports['qb-core']:AddGangs

exports['qb-core']:AddGangs(gangs --[[table]])-- Exampleexports['qb-core']:AddGangs({ ['lostmc'] = { label = 'Lost MC', grades = { ['0'] = { name = 'Recruit' } } }, ['ballas'] = { label = 'Ballas', grades = { ['0'] = { name = 'Recruit' } } }})

Import Items

  • This method allows for any resource to insert item data into the shared file for the core. That means that you can make a resource, and on load, make those items available for use. This can be accomplished through one the ways shown below. Utilizing the function requires importing the core but using the export does not

QBCore.Functions.AddItem

QBCore.Functions.AddItem(itemName --[[string]], item --[[table]])-- ExampleQBCore.Functions.AddItem('water_bottle', { name = 'water_bottle', label = 'Bottle of Water', weight = 10, type = 'item', image = 'water_bottle.png', unique = false, useable = true, shouldClose = true, combinable = nil, description = 'For all the thirsty out there'})

exports['qb-core']:AddItem

exports['qb-core']:AddItem(itemName --[[string]], item --[[table]])-- Exampleexports['qb-core']:AddItem('water_bottle', { name = 'water_bottle', label = 'Bottle of Water', weight = 10, type = 'item', image = 'water_bottle.png', unique = false, useable = true, shouldClose = true, combinable = nil, description = 'For all the thirsty out there'})

QBCore.Functions.AddItems

QBCore.Functions.AddItems(items --[[table]])-- ExampleQBCore.Functions.AddItems({ ['water_bottle'] = { name = 'water_bottle', label = 'Bottle of Water', weight = 10, type = 'item', image = 'water_bottle.png', unique = false, useable = true, shouldClose = true, combinable = nil, description = 'For all the thirsty out there' }, ['sandwich'] = { name = 'sandwich', label = 'Sandwich', weight = 10, type = 'item', image = 'sandwich.png', unique = false, useable = true, shouldClose = true, combinable = nil, description = 'Nice bread for your stomach' }})

exports['qb-core']:AddItems

exports['qb-core']:AddItems(items --[[table]])-- Exampleexports['qb-core']:AddItems({ ['water_bottle'] = { name = 'water_bottle', label = 'Bottle of Water', weight = 10, type = 'item', image = 'water_bottle.png', unique = false, useable = true, shouldClose = true, combinable = nil, description = 'For all the thirsty out there' }, ['sandwich'] = { name = 'sandwich', label = 'Sandwich', weight = 10, type = 'item', image = 'sandwich.png', unique = false, useable = true, shouldClose = true, combinable = nil, description = 'Nice bread for your stomach' }})
Shared Exports | QBCore Documentation (2024)
Top Articles
Latest Posts
Article information

Author: Lidia Grady

Last Updated:

Views: 5952

Rating: 4.4 / 5 (65 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Lidia Grady

Birthday: 1992-01-22

Address: Suite 493 356 Dale Fall, New Wanda, RI 52485

Phone: +29914464387516

Job: Customer Engineer

Hobby: Cryptography, Writing, Dowsing, Stand-up comedy, Calligraphy, Web surfing, Ghost hunting

Introduction: My name is Lidia Grady, I am a thankful, fine, glamorous, lucky, lively, pleasant, shiny person who loves writing and wants to share my knowledge and understanding with you.