Saltar al contenido
QBCore quick start

QBCore quick start

Install QBCore with the txAdmin recipe, understand its folders, make yourself admin, add a job and a usable item, write a small QBCore script, and avoid common pitfalls.

Esta documentación está en inglés por ahora.

Last updated

QBCore is one of the most popular FiveM roleplay frameworks, with the largest catalogue of compatible scripts. This quick start gets a QBCore server running and shows you how to add your own job, item and script. Official docs: qbcore.org/docs.

Plays from youtube-nocookie.com after you click.

1. Install with txAdmin

Requirements: an artifact, a license key, and MariaDB (QBCore’s guide pairs it with HeidiSQL, see Database setup).

  1. Start FXServer, link your Cfx.re account in txAdmin.
  2. Choose Popular Recipes > QBCore.
  3. Enter your license key and the database connection (leave the database name empty).
  4. Run Recipe, then Save & Run Server.

Important

On the first start, some resources build with yarn. QBCore’s docs say to let yarn install run all the way through before restarting.

What the recipe installs is listed in Popular recipes. Its server.cfg enforces game build 3095, sets setr qb_locale "en" and setr UseTarget false.

2. The folder structure

Text
resources/
├─ [cfx-default]/     Cfx default resources
├─ [standalone]/      oxmysql, PolyZone, connectqueue, progressbar, bob74_ipl...
├─ [voice]/           pma-voice, qb-radio
├─ [defaultmaps]/     hospital, dealer, prison maps
└─ [qb]/
   ├─ qb-core/        the framework
   │  ├─ config.lua
   │  ├─ shared/      jobs.lua, gangs.lua, items.lua, vehicles.lua, weapons.lua, locations.lua
   │  ├─ server/
   │  └─ client/
   ├─ qb-inventory/
   ├─ qb-policejob/ ...

qb-core/shared/*.lua is where most “data” lives: jobs, gangs, items, vehicles.

3. Make yourself admin

The recipe’s server.cfg builds a permission chain:

server.cfg (from the QBCore recipe)
add_ace qbcore.god command allow
add_principal qbcore.god group.admin
add_principal qbcore.god qbcore.admin
add_principal qbcore.admin qbcore.mod

Add yourself to qbcore.god with your identifier (find it in txAdmin’s player info):

server.cfg
add_principal identifier.fivem:123456 qbcore.god
# or: add_principal identifier.license:abcdef... qbcore.god

Restart, join, and try /admin for qb-adminmenu. txAdmin’s own menu (/tx) works independently of this.

Plays from youtube-nocookie.com after you click.

4. Add a job

Jobs are in qb-core/shared/jobs.lua. Copy an existing entry:

qb-core/shared/jobs.lua
QBCore.Shared.Jobs = {
    -- ...existing jobs...
    burgershot = {
        label = 'Burger Shot',
        defaultDuty = true,
        offDutyPay = false,
        grades = {
            ['0'] = { name = 'Trainee', payment = 50 },
            ['1'] = { name = 'Cook', payment = 75 },
            ['2'] = { name = 'Manager', isboss = true, payment = 120 },
        },
    },
}
  • The key (burgershot) is the job name scripts check.
  • Grades are string keys ('0', '1') in QBCore.
  • isboss = true gives access to the boss menu (qb-management).

Restart qb-core (or the server) and give yourself the job: /setjob [your id] burgershot 2.

5. Add a usable item

Items live in qb-core/shared/items.lua:

qb-core/shared/items.lua
QBCore.Shared.Items = {
    -- ...
    burger = {
        name = 'burger',
        label = 'Burger',
        weight = 250,
        type = 'item',
        image = 'burger.png',
        unique = false,
        useable = true,
        shouldClose = true,
        description = 'A juicy Burger Shot burger',
    },
}

Put burger.png in the inventory’s image folder (qb-inventory/html/images/). The Inventory Icons tool makes transparent item images from prop pictures or your own images.

Make it do something when used, in a server script of your own resource:

my_food/server.lua
local QBCore = exports['qb-core']:GetCoreObject()

QBCore.Functions.CreateUseableItem('burger', function(source, item)
    local Player = QBCore.Functions.GetPlayer(source)
    if not Player then return end
    if Player.Functions.RemoveItem(item.name, 1, item.slot) then
        TriggerClientEvent('my_food:eat', source)
        -- raise hunger through your HUD/status resource here
    end
end)

Give it to yourself with /giveitem [your id] burger 1.

6. A small QBCore script

A /paycheck command that pays bank money based on the player’s job grade, with server side checks:

my_paycheck/fxmanifest.lua
fx_version 'cerulean'
game 'gta5'
server_script 'server.lua'
dependency 'qb-core'
my_paycheck/server.lua
local QBCore = exports['qb-core']:GetCoreObject()
local lastClaim = {}

QBCore.Commands.Add('paycheck', 'Claim a bonus paycheck (once per hour)', {}, false, function(source)
    local src = source
    local Player = QBCore.Functions.GetPlayer(src)
    if not Player then return end

    local cid = Player.PlayerData.citizenid
    if lastClaim[cid] and os.time() - lastClaim[cid] < 3600 then
        TriggerClientEvent('QBCore:Notify', src, 'You already claimed it this hour', 'error')
        return
    end

    local job = Player.PlayerData.job
    local amount = 100 + (job.grade.level * 50)
    Player.Functions.AddMoney('bank', amount, 'paycheck-bonus')
    lastClaim[cid] = os.time()
    TriggerClientEvent('QBCore:Notify', src, ('Paid $%d for %s'):format(amount, job.label), 'success')
end)

Useful player data: Player.PlayerData.citizenid, .charinfo (first and last name), .job (name, label, grade.level, onduty), .gang, .money (cash, bank, crypto), .metadata.

Common pitfalls

  • Editing shared/*.lua on a live server: other resources cache shared data. Restart the server after changing jobs or items.
  • Old tutorials: QBCore has changed a lot. Code with TriggerEvent('QBCore:GetObject', ...) is outdated: use exports['qb-core']:GetCoreObject().
  • Modified forks: many paid scripts expect a stock or a specific version of QBCore. Keep a note of what you changed in core files, or better, don’t change core files.
  • qb-target vs ox_target: UseTarget is false by default in the recipe. Decide early and configure resources to match.
  • Performance: the full recipe runs many resources you may not need. Remove jobs and systems you don’t use, check resmon.
  • XAMPP: use a real MariaDB.

Next steps

  • Browse qbcore.org/docs for each resource’s config.
  • Swap in ox_inventory if you want it (the QBCore docs and ox_inventory’s docs cover the conversion).
  • The video archive has a frameworks course with QBCore installs and follow ups.