Risparmia oggi con 20% Usa il codice WELCOME al pagamento. WELCOME

Qbox Framework Guide for FiveM

Testare uno script gratuito?

Gli script gratuiti vanno bene per controlli rapidi. Per server in produzione, confronta pacchetti server completi o script a pagamento mantenuti, in base al framework e al caso d'uso.

Fast answer: Qbox is a modern FiveM framework direction commonly used with the overextended stack, including ox_lib, ox_inventory, and ox_target-style workflows. Before migrating from QBCore, audit resources, exports, database tables, inventory, jobs, and admin tooling.

Last updated: June 25, 2026

Overextended (Ox) is the modern baseline for FiveM servers. This guide shows you how to install, configure, and safely migrate to inventario_di_bue, ox_lib, bersaglio_ox, E oxmysql. You’ll get copy‑pasteable code, opinionated defaults, and battle‑tested patterns for UI, interactions, and data. Includes playbooks for qb-inventory → ox_inventory E mysql-async → oxmysql. Back up your server and database before any change.


TL;DR: Which Ox component for what?

ComponenteScopoCore APIsTypical UseMigration PathCommon Gotchas
inventario_di_bueInventory & items, stashes, shopsAddItem, RemoveItem, RegistratiNascondi, RegisterShopPlayer items, job stashes, vendor shopsqb-inventory → ox_inventoryWrong item schema, duplicate invs running, missing garantire ordine
ox_libUtilities, UI, helpersaddCommand, registerContext/showContext, inputDialog, progressBar, zones/pointsMenus, prompts, rate‑limits, zone logicN / AMixing UI libs, not awaiting callbacks
bersaglio_oxInteraction targetingaddBoxZone, addSphereZone, addEntity, addModelEye targets on props/peds/zonesqtarget → ox_target (optional)Overlapping zones, missing job conditions
oxmysqlMySQL driverquery, single, scalar, insert, prepare, transactionDB persistence, leaderboards, auditsmysql-async → oxmysqlUnindexed queries, unsafe string concat

Mancia: Inizia con oxmysql E ox_lib, then migrate inventory E bersaglio. Validate each step on a staging server.

Imparentato: https://fivemx.com/frameworks/ · https://fivemx.com/framework-conversion/

Get QBox Scripts here


Prerequisites & Baseline

  • Recent server artifact, txAdmin, and a framework (QBCore O ESX).
  • Node.js is not required for Ox, but your NUI stack (if any) might use it.
  • Resource start order: oxmysqlox_libinventario_di_bue → the rest. Put bersaglio_ox early among UI/interact libs.
  • Lista di controllo:
    • Firewall allows DB traffic; DB user has least privileges.
    • Set production vs dev convars; enable slow query warnings in staging.
    • Backups for DB and resource configs.

Imparentato: https://fivemx.com/how-to-install-qbcore/ · https://fivemx.com/how-to-customize-qbcore-scripts/ · https://fivemx.com/qbcore-scripts/


Install & Configure: ox_inventory

Installare

Add the resource and ensure it Dopo ox_lib.

-- resources/[ox]/ox_inventory/fxmanifest.lua (snippet)
fx_version 'cerulean'
game 'gta5'

lua54 'yes'
shared_scripts {
  '@ox_lib/init.lua',
  'config.lua'
}
client_scripts { 'client/*.lua' }
server_scripts { '@oxmysql/lib/MySQL.lua', 'server/*.lua' }

server.cfg:

ensure oxmysql
ensure ox_lib
ensure ox_inventory

Core config

Define items (weight, stack, metadata). Typical path: ox_inventory/data/items.lua.

return {
  water = {
    label = 'Water Bottle',
    weight = 200,
    stack = true,
    close = true,
    description = 'Stay hydrated.'
  },
  sandwich = { label = 'Sandwich', weight = 300, stack = true }
}

Register a stash e un negozio on server start:

-- server/stash_shop.lua
CreateThread(function()
  exports.ox_inventory:RegisterStash('pd_evidence', 'Police Evidence', 100, 100000, false, {police = 2})

  exports.ox_inventory:RegisterShop('corner_store', {
    name = '24/7 Market',
    inventory = {
      { name = 'water', price = 8 },
      { name = 'sandwich', price = 12 }
    }
  })
end)

UI basics

  • Drag & drop, split, stack; configurable hotkeys.
  • Utilizzo metadati for serials, qualities, expiry.

Quick test

Give yourself an item and open inventory:

-- server/debug.lua
RegisterCommand('giveme', function(src)
  exports.ox_inventory:AddItem(src, 'water', 1)
end, true)

Errori comuni

Avvertimento: Fare non run two inventories at once. Fully disable qb-inventory before enabling ox_inventory.

Mancia: Match item names exactly across jobs/crafting and inventory data.

Imparentato: https://fivemx.com/fivem-inventory-scripts/ · https://fivemx.com/qbcore-scripts/


Install & Configure: ox_lib

Elementi essenziali

Nucleo helpers you’ll use everywhere:

-- Commands
lib.addCommand('healme', {
  help = 'Heal yourself (admin only).',
  restricted = 'group.admin'
}, function(src)
  TriggerClientEvent('fivemx:heal', src)
end)

-- Context menus
lib.registerContext({
  id = 'shop_menu',
  title = '24/7 Market',
  options = {
    { title = 'Buy Water ($8)', event = 'fivemx:buy', args = { item = 'water', price = 8 } },
    { title = 'Buy Sandwich ($12)', event = 'fivemx:buy', args = { item = 'sandwich', price = 12 } }
  }
})
-- later
lib.showContext('shop_menu')

Mini cookbook

  • Input dialog e progressi with awaitable flow:
-- client
local input = lib.inputDialog('Craft Coffee', {
  { type = 'number', label = 'Beans (g)', default = 18, min = 1, max = 60 }
})
if input then
  local ok = lib.progressBar({ duration = 3500, label = 'Brewing…', useWhileDead = false, canCancel = true })
  if ok then TriggerServerEvent('fivemx:craft:coffee', input[1]) end
end
  • Richiamate (server validates, client awaits):
-- server
lib.callback.register('fivemx:buyItem', function(src, item, price)
  -- validate job/coords/etc. then charge + grant
  -- return true/false and message
  return exports.ox_inventory:AddItem(src, item, 1)
end)

-- client
local success = lib.callback.await('fivemx:buyItem', false, 'water', 8)

Imparentato: https://fivemx.com/frameworks/ · https://fivemx.com/framework-conversion/


Install & Configure: ox_target

Entities & bones

Attach actions to specific peds/vehicles/objects or their bones.

-- target an entity by model
exports.ox_target:addModel(`prop_vend_soda_02`, {
  {
    name = 'vending_buy',
    icon = 'fa-solid fa-bottle-water',
    label = 'Buy a Drink',
    onSelect = function(data) TriggerEvent('fivemx:openVending') end
  }
})

Zones

Create 3D boxes/spheres/polys with job conditions.

-- Box zone in front of cash register
exports.ox_target:addBoxZone({
  coords = vec3(25.7, -1347.3, 29.5),
  size = vec3(1.6, 1.2, 1.0),
  rotation = 0.0,
  debug = false,
  options = {
    {
      label = 'Open Shop',
      icon = 'fa-solid fa-store',
      groups = { police = 0, ambulance = 0 }, -- anyone; example of group filter
      onSelect = function()
        lib.showContext('shop_menu')
      end
    }
  }
})

Esempi

  • Stash target for police evidence.
  • Job‑gated crafting inside a workshop.

Imparentato: https://fivemx.com/qbcore-scripts/ · https://fivemx.com/fivem-inventory-scripts/


Install & Configure: oxmysql

Why oxmysql

  • Prepared statements, pooling, async/await API.
  • Better performance and safety than string‑concat SQL.

API cheatsheet

-- read many
local rows = MySQL.query.await('SELECT id, name FROM players WHERE job = ?', { 'police' })

-- read single row
local player = MySQL.single.await('SELECT * FROM players WHERE identifier = ?', { identifier })

-- scalar value
local count = MySQL.scalar.await('SELECT COUNT(*) FROM stash_items WHERE stash = ?', { 'pd_evidence' })

-- insert
local id = MySQL.insert.await('INSERT INTO logs (event, source) VALUES (?, ?)', { 'buy_water', src })

-- prepared & cached
local info = MySQL.prepare.await('SELECT label, weight FROM items WHERE name = ?', { 'water' })

-- transaction
MySQL.transaction.await(function()
  MySQL.query.await('UPDATE accounts SET money = money - ? WHERE identifier = ?', { 12, identifier })
  MySQL.query.await('INSERT INTO purchases (identifier, item) VALUES (?, ?)', { identifier, 'sandwich' })
end)

Indexes & schema hygiene

ALTER TABLE players ADD INDEX idx_players_identifier (identifier);
ALTER TABLE purchases ADD INDEX idx_purchases_identifier_created (identifier, created_at);

Error handling

Mancia: Enable slow query warnings in staging and add proper indexes before launch.

Imparentato: https://fivemx.com/mysql-async-to-oxmysql/ · https://fivemx.com/sql-identifiers-migration/ · https://fivemx.com/converting-fivem-scripts/


Migration Playbooks (copy-paste ready)

qb-inventory → ox_inventory

Concepts mapping

Concettoqb-inventarioinventario_di_bue
Elementiqb-core/shared/items.luaox_inventory/data/items.lua
StashesJob/player stash logic in scriptsRegisterStash(id, label, slots, weight, owner, groups, coords)
Negoziqb-shops or customRegisterShop(id, { inventory = {..} })

Passi

  1. Disable qb-inventory and any inventory‑dependent UIs.
  2. Installare ox_lib, inventario_di_bue, oxmysql in that order.
  3. Port items → dati/elementi.lua (preserve names/weights/metadata).
  4. Replace item add/remove calls with exports.ox_inventory:AddItem/RemoveItem.
  5. Register stashes/shops server‑side; migrate stash save data if applicable.
  6. Test on staging; verify drag/stack/split and job stashes.

Checklist (Before/After)

ZonaPrimaDopoRisk
Risorseqb-inventory enabledqb-inventory removed, ox_inventory ensuredBasso
Elementiitems in qb shareditems in dati/elementi.luaMedium (naming)
Stashesimplicitexplicit RegistratiNascondiBasso
Negoziqb‑shopsRegisterShopBasso

Example: add/remove replace

-- before (qb-inventory pseudocode)
-- QBCore.Functions.AddItem(src, 'water', 1)

-- after (ox_inventory)
exports.ox_inventory:AddItem(src, 'water', 1)
exports.ox_inventory:RemoveItem(src, 'sandwich', 1)

Imparentato: https://fivemx.com/fivem-inventory-scripts/


mysql-async → oxmysql

Search/replace patterns

mysql-async calloxmysql equivalent
MySQL.Async.fetchAll(sql, parametri, cb)MySQL.query(sql, params) / .attendere
MySQL.Async.fetchScalar(sql, params, cb)MySQL.scalar(sql, params) / .attendere
MySQL.Async.execute(sql, parametri, cb)MySQL.query(sql, params) O MySQL.update/insert / .attendere
string concat "..var.."? placeholders with param array
manual BEGIN/COMMITMySQL.transaction.await(function() ... end)

Example refactor

-- before
MySQL.Async.fetchAll('SELECT * FROM users WHERE identifier = @id', { ['@id'] = identifier }, function(rows)
  -- use rows
end)

-- after
local rows = MySQL.query.await('SELECT * FROM users WHERE identifier = ?', { identifier })

Prepared statements

local user = MySQL.prepare.await('SELECT id, job FROM users WHERE identifier = ?', { identifier })

Avvertimento: Never trust client input. Always validate on the server and use placeholders.

Imparentato: https://fivemx.com/mysql-async-to-oxmysql/ · https://fivemx.com/sql-identifiers-migration/ · https://fivemx.com/converting-fivem-scripts/


Patterns that sell: building jobs & UI with the Ox stack

A minimal delivery job that ties bersaglio_ox (interact), ox_lib (UI), inventario_di_bue (rewards), and oxmysql (audit).

-- client/jobs_delivery.lua
local drop = vec3(120.4, -1039.2, 29.2)
exports.ox_target:addBoxZone({
  coords = drop, size = vec3(1.4, 1.0, 1.0), rotation = 340.0,
  options = {
    {
      name = 'deliver_crate', label = 'Deliver Crate', icon = 'fa-solid fa-box',
      onSelect = function()
        local ok = lib.progressBar({ duration = 4000, label = 'Dropping off…' })
        if ok then TriggerServerEvent('fivemx:job:deliverCrate') end
      end
    }
  }
})
-- server/jobs_delivery.lua
RegisterNetEvent('fivemx:job:deliverCrate', function()
  local src = source
  -- rate limit per minute (very simple)
  local ok = exports.ox_inventory:AddItem(src, 'water', 1)
  if ok then
    MySQL.insert.await('INSERT INTO job_logs (identifier, event) VALUES (?, ?)', { GetPlayerIdentifier(src, 0), 'deliver_crate' })
    TriggerClientEvent('ox_lib:notify', src, { title = 'Delivery', description = 'You received Water x1', type = 'success' })
  end
end)

Imparentato: https://fivemx.com/qbcore-scripts/ · https://fivemx.com/fivem-inventory-scripts/


Performance & Security

  • Debounce target interactions; avoid overlapping zones.
  • Cache frequent reads; index columns used in WHERE/JOIN.
  • Keep server ticks low; move heavy loops off the main thread.
  • Security: validate server‑side, rate‑limit economic actions, log sensitive events.

Mancia: Turn on slow‑query warnings in staging; ship indexes with migrations.

Imparentato: https://fivemx.com/converting-fivem-scripts/ · https://fivemx.com/sql-identifiers-migration/


Debugging & Test Harness

  • Add debug commands guarded by permissions.
  • Log DB failures and short‑circuit on errors.
  • Test hot‑reload by restarting single resources (not the whole stack).
lib.addCommand('oxping', { help = 'Health check', restricted = 'group.admin' }, function(src)
  local ok = MySQL.scalar.await('SELECT 1') == 1
  TriggerClientEvent('ox_lib:notify', src, { title = 'Ox Health', description = ok and 'DB OK' or 'DB FAIL', type = ok and 'success' or 'error' })
end)

Imparentato: https://fivemx.com/frameworks/ · https://fivemx.com/framework-conversion/


Risorse interne e prossimi passi

Browse the store for tested scripts that follow these patterns.


Domande frequenti

Is ox_inventory faster than qb-inventory?
Generally yes. It emphasizes efficient UI and server‑side operations with sane defaults for stacks, weights, and metadata.

Can I mix qb-inventory and ox_inventory?
Not recommended. Stop qb-inventory entirely before enabling ox_inventory to avoid duplicate handlers and item desync.

Do I need to rewrite SQL for oxmysql?
Mostly search/replace. Replace string concat with placeholders, adopt *.attendere APIs, and add missing indexes.

How do I secure ox_target interactions?
Utilizzo gruppi/job checks client‑side but always re‑validate on the server (distance, job, item ownership) before rewards.

What about ESX compatibility?
The Ox stack is framework‑agnostic. Map ESX events to server handlers and keep inventory names consistent.

How do I benchmark DB calls?
Use EXPLAIN, enable slow‑query warnings, and compare timings before/after adding indexes.

Where do I define items for ox_inventory?
In ox_inventory/data/items.lua. Keep labels short and weights realistic.

Can I keep qtarget while migrating to ox_target?
Temporarily, but avoid overlapping zones. Migrate feature‑by‑feature and remove qtarget when parity is reached.

How do I migrate stash data?
Create equivalent RegistratiNascondi entries and run SQL to rename old stash IDs to the new keys if needed. Test on staging.

How do I set weights and limits?
Weights live in elementi.lua. Stash/shop capacities are part of RegistratiNascondi/RegisterShop args.

How do I rate‑limit purchases or jobs?
Utilizzo lib.addCommand/callbacks with simple in‑memory cooldowns and server‑side validation.

Does oxmysql support transactions?
Yes—wrap atomic sequences in MySQL.transaction.await(function() ... end).

How do I handle NUI with Ox?
Ox plays fine with any NUI; just keep heavy UI logic client‑side and validations server‑side.

What’s the safest migration order?
oxmysql → ox_lib → ox_inventory → ox_target. Validate after each step.


Changelog e crediti

VersioneDataNote
v1.02025-09-05Initial publication with install, config, and migration playbooks.

Ultimo aggiornamento: 2025-09-05

Credits & sources: Overextended documentation (ox_inventory, ox_lib, ox_target), oxmysql reference, Cfx.re docs, and community best practices.


Conclusione e prossimi passi

Entrambi i framework possono gestire una città di alto livello. La differenza sta nel livello di eredità che si desidera portare con sé e nel livello di standardizzazione che si desidera per il futuro.

Prossimi passi:


Riferimenti esterni (scopri di più)

Migration checks

  • List every resource that calls QBCore exports or events.
  • Check inventory compatibility before changing item definitions.
  • Test shops, jobs, player loading, money, vehicles, and housing on staging.
  • Review ox_lib callbacks and notifications where scripts already depend on them.
  • Keep a database rollback before changing live framework tables.
Luca
Luca

Mi chiamo Luke, sono un giocatore e amo scrivere di FiveM, GTA e giochi di ruolo. Gestisco una community di gioco di ruolo e ho circa 10 anni di esperienza nell'amministrazione di server.

Articoli: 436

Lascia una risposta