๐Ÿ“œ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

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

QBShared.StarterItems = {
    phone = 1,
    id_card = 1,
    driver_license = 1,
}

Example Usage:

for item, amount in pairs(QBCore.Shared.StarterItems) do
    local item_info = QCore.Shared.Items[item]
    print('Received '..amount..' '..item_info.label)
end

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 split

  • delimiter: string - The character or sequence used to split the string

  • returns: table

Example Usage:

Trim WhiteSpace

Removes leading and trailing whitespace from a string

  • value: string - The string to trim

  • returns: 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 round

  • numDecimalPlaces (optional): number - The number of decimal places to round to

  • returns: number

Example Usage:

Change Vehicle Extra

Toggles an extra on a vehicle

  • vehicle: number - The vehicle entity

  • extra: number - The extra ID

  • enable: 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 entity

  • config: 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.

Property
Type
Description

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

Property
Type
Description

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

Property
Type
Description

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

Property
Type
Description

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

Property
Type
Description

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

  • 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.

Property
Type
Description

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.

category

string

The category of the vehicle (e.g., "compacts", "sports"). Use GetVehicleClass

type

string

The type of vehicle (e.g., "automobile", "bike"). Refer to Vehicle Types

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

Sometimes you only have the vehicle hash to work with so you can look it up following the example below!

Weapons

  • 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

Property
Type
Description

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

Was this helpful?