📜Shared
Learn how to manage your server's jobs, vehicles, items, etc!
Introduction
The shared folder inside qb-core contains all the information for your jobs, vehicles, items & more! You will spend a lot of time in this folder configuring everything to your exact specifications. Jenkins hashes are used frequently, you can find more information on those here
QBCore uses Lua tables for storing static information instead of relying on a database. This avoids the need for frequent database queries, resulting in faster operations. Combined with Shared Exports it can be a very powerful tool!
Utility
Found in
qb-core/shared/main.lua
Starting Items
Starter items are predefined items that a player receives when joining the server for the first time
item_name:
string
amount:
number
Example Usage:
Generate a Random String
Generates a random string of a specified length
length:
number
returns:
string
Example Usage:
Generate a Random Integer String
Generates a random numeric string of a specified length
length:
number
returns:
string
Example Usage:
Split a String
Splits a string into parts based on a delimiter
str:
string
- The string to splitdelimiter:
string
- The character or sequence used to split the stringreturns:
table
Example Usage:
Trim WhiteSpace
Removes leading and trailing whitespace from a string
value:
string
- The string to trimreturns:
string
Example Usage:
Round a Number
Rounds a number to the nearest whole number or to a specified number of decimal places
value:
number
- The number to roundnumDecimalPlaces (optional):
number
- The number of decimal places to round toreturns:
number
Example Usage:
Change Vehicle Extra
Toggles an extra on a vehicle
vehicle:
number
- The vehicle entityextra:
number
- The extra IDenable:
boolean
- Whether to enable/disable the extra
Example Usage:
Set Default Vehicle Extras
Resets all extras on a vehicle and applies a specified configuration
vehicle:
number
- The vehicle entityconfig:
table
- A table defining which extras to enable/disable
Example Usage:
Items
Found in
qb-core/shared/items.lua
The Items
table in qb-core defines all the items available in your server. Each item is represented as an object with several properties that determine its behavior, appearance, and functionality.
name
string
The internal name used for spawning, giving, or removing the item.
label
string
The display name shown in the inventory.
weight
number
The weight of the item, affecting inventory capacity.
type
string
The type of item (e.g., item
, weapon
).
image
string
The filename of the item's image located in qb-inventory/html/images
.
unique
boolean
Whether the item is unique (true
) or stackable (false
).
useable
boolean
Whether the item is usable. Must still be registered as a usable item.
shouldClose
boolean
Whether using the item closes the inventory (true
or false
).
description
string
A short description of the item shown in the inventory.
Example: Basic Item Definition
Jobs
Found in
qb-core/shared/jobs.lua
The Jobs
table in qb-core defines all the jobs available on your server, including their ranks, salaries, and specific features. This allows you to manage employment roles, responsibilities, and pay structures effectively.
Example: Global Setting
The global setting determines if the duty state should default to the defaultDuty
setting of the job upon login or persist based on the last saved state in the database:
Job Object Layout
label
string
The display name of the job.
type
string
The type of job (e.g., leo
for law enforcement officer).
defaultDuty
boolean
Whether the player is automatically on duty when they log in.
offDutyPay
boolean
Whether the player receives a paycheck while off duty.
grades
table
A table defining job grades, including names, payment, and other rank-specific attributes.
Grades Table Layout
name
string
The name of the grade (e.g., Recruit, Officer).
payment
number
The salary for this grade.
isboss
boolean
(Optional) If true
, this grade is marked as the boss (e.g., Chief).
Example: Basic Job Definition
This example defines the unemployed job with a single grade:
Example: Advanced Job Definition
This example defines the police job with multiple grades, each with specific attributes:
Gangs
Found in
qb-core/shared/gangs.lua
The Gangs
table in qb-core defines all the gangs available on your server, including their ranks, salaries, and specific features. This allows you to manage member roles, responsibilities, and pay structures effectively.
Gang Object Layout
label
string
The display name of the gang
grades
table
A table defining gang grades, including names and other rank-specific attributes.
Grades Table Layout
name
string
The name of the grade (e.g., Recruit, Enforcer).
isboss
boolean
(Optional) If true
, this grade is marked as the boss (e.g., Boss).
Example: Basic Gang Definition
This example defines the unemployed gang with a single grade:
Example: Advanced Gang Definition
This example defines the lost mc gang with multiple grades, each with specific attributes:
Vehicles
If you want to save a vehicle to the database for ownership, it MUST be defined in the shared vehicles table!
Found in
qb-core/shared/vehicles.lua
The Vehicles
table in qb-core defines all the vehicles available on your server, including their properties and categories. This table allows you to configure specific attributes for each vehicle to control how they behave in-game.
model
string
The spawn code of the vehicle (must match the model name in the game).
name
string
The display name of the vehicle shown to players.
brand
string
The brand or manufacturer of the vehicle (e.g., "Maxwell", "Karin").
price
number
The price of the vehicle in in-game currency.
shop
string | table
The shop(s) where the vehicle is available. Can be a single shop (e.g., "pdm") or multiple shops as a table
We automatically index the QBShared.Vehicles table with the model of the vehicle! So you can access it's properties via QBCore.Shared.Vehicles[model]
We also create a table called QBShared.VehicleHashes
which stores the hash of the vehicle as the key!
Sometimes you only have the vehicle hash to work with so you can look it up following the example below!
Weapons
Weapons are added in shared/items.lua as well to use as items! This table is only for looking up weapon information via it's hash which is returned via GetCurrentPedWeapon or similar native function that returns the weapons hash
Found in
qb-core/shared/weapons.lua
The Weapons
table in qb-core defines all the weapons available on your server. It includes attributes like the weapon's name, label, type, ammo type, and a damage reason for death notifications. This table allows you to manage and customize the weapons players can access.
Weapon Object Layout
name
string
The internal spawn name of the weapon (e.g., weapon_pistol
).
label
string
The display name of the weapon shown to players.
weapontype
string
The type of weapon (e.g., "Pistol", "Shotgun", "Rifle").
ammotype
string
The type of ammo the weapon uses (e.g., AMMO_PISTOL
, AMMO_SHOTGUN
).
damagereason
string
A customizable message that appears in kill notifications to describe the cause of death.
Last updated