Converting from QBCore

Converting from QBCore

We highly recommend installing Qbox via the recipe to avoid as many issues as possible.
For detailed instructions, refer to Installation.

Update your server configuration files.

When installing Qbox via the recipe, the server.cfg, ox.cfg, permissions.cfg, and voice.cfg files will be download automatically. If you are not using the recipe, you will need to manually add/update these. See the Qbox txAdminRecipe repository (opens in a new tab) for the latest versions of these files.

Update your job grades in qbx_core/shared/jobs.lua.

In Qbox, job grades are numbers without quotations, whereas in QBCore they are strings. These will need to be changed.

Configure ox_inventory and convert your database.

Back it up first! (see ox_inventory documentation (opens in a new tab))

Update qbx_core's job and gang shared files.

In Qbox, the job and gang grades are numbers without quotations whereas in QBCore, they are strings. These will need to be changed. The job and gang shared files are located in qbx_core/shared/jobs.lua and qbx_core/shared/gangs.lua respectively.

Configure qbx_core's built-in functionalities.

Qbox has a multicharacter, queue, multijob, and Discord rich presense built into qbx_core. By default, all of these are enabled. If you wish to disable or customize these, do the following:

  • To disable the multicharacter system, open qbx_core/config/client.lua and set useExternalCharacters to false.
  • To disable the queue system, open the server.cfg file and set qbx:enablequeue to false. To customize the queue system further, open qbx_core/config/queue.lua.
  • To disable or customize the Discord rich presents, open qbx_core/config/client.lua, scroll all the way down, and edit the discord table.
  • To customize the multijob/multigang system, open the server.cfg file and set qbx:max_jobs_per_player and qbx:max_gangs_per_player to the desired values. This feature cannot be disabled.
    • First, double check that the player.citizenid column in your database has the proper utf8mb4_unicode_ci collation. If not, change it. Then, run the qbx_core.sql file to create the new player_groups table.
    • Start the server and then type convertjobs into the txAdmin colsone once the server is running to populare the player_groups table.
    • Do not use external multijob/multigang resources that aren't guaranteed to be Qbox compatible. Using incompatible multijobs or resources which modify the core's database tables may lead to data corruption!

Run the SQL file provided with qbx_core

This will alter the players table in the following ways:

  • Add to the players table to add the new column last_logged_out
  • Change the collation of players.citizenid column to utf8mb4_unicode_ci

Note: You may need to manually change the collation of other tables' citizenid column if you get an error that a foreign key constraint was violated.

Migrating a resource from QBCore to Qbox

This is optional as Qbox has 99% compatibility with existing QB scripts

Within Qbox, the core object no longer exists. Instead, the data can be accessed via a combination of export functions and imported modules.

  1. Import the needed modules from qbx_core to supply replacement functions for ones from QBCore
  2. Replace calls to QBCore one by one with calls to the imported modules and exported functions. Both can be used at the same time, so conversion can be done partially, or over time.

Common replacements

QBCore.Functions. -> exports.qbx_core:
QBCore.Functions.GetPlayerData() -> QBX.PlayerData -- requires importing the playerdata module
QBCore.Functions.GetPlate(vehicle) -> qbx.getVehiclePlate(vehicle) -- requires importing the lib module
QBCore.Shared.Jobs -> exports.qbx_core:GetJobs()
QBCore.Shared.Gangs -> exports.qbx_core:GetGangs()
QBCore.Shared.Vehicles -> exports.qbx_core:GetVehiclesByName()
QBCore.Shared.Weapons -> exports.qbx_core:GetWeapons()
QBCore.Shared.Locations -> exports.qbx_core:GetLocations()
QBCore.Shared.Items -> exports.ox_inventory:Items()
 
exports['qb-core']:KeyPressed() -> lib.hideTextUI()
exports['qb-core']:HideText() -> lib.hideTextUI()
exports['qb-core']:DrawText(text, position) -> lib.showTextUI(text, { position = position })
exports['qb-core']:ChangeText(text, position) -> lib.hideTextUI() lib.showTextUI(text, { position = position })