Core Object
Let's dive into the core object of the qb-core resource!
Introduction
The Core Object is the backbone of the qb-core
framework, providing essential functionality and utilities for managing your server's gameplay mechanics, player data, and overall resource interactions. This page will guide you through the key features, methods, and best practices for using the Core Object effectively
How to Access the Core Object
We recommend using the core objects filtering capabilities instead of importing it all unless you need it!
To interact with the Core Object in your scripts, use the following pattern at the top of your script:
Always cache the Core Object in a local variable to avoid repeated calls to
exports
As of qb-core
version 1.3.0 (check your fxmanifest.lua) you can decide what you want to get from the core object instead of importing it all! This change was made to reduce the amount of memory being stored inside each script because importing the full core brought a lot of overhead that wasn't needed.
Exported Functions
As of
qb-core
version 1.3.0 (check your fxmanifest.lua) all functions within the core object are exported so if you only need a single one you don't have to import them all! This is very handy if you are a script creator supporting different frameworks and don't need all the core information. You can now just call the functions you need.
Core Features
Functions
A collection of utility functions for common server and player operations.
Players
A table containing all currently connected players.
Shared
Shared data like items, vehicles, and jobs.
Config
The main configuration table for qb-core
Commands
A registry for custom server and client commands.
Example Usage
Accessing Player Data
You can use the Core Object to retrieve a player's data
Using Shared Data
Access shared data like items, vehicles, or jobs
Registering Commands
The Core Object allows you to register custom commands for your server
Last updated