Converting from QBCore

Converting from QBCore

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

In Qbox, job grades are numbers without quotations, whereas in QBCore they are strings.

Configure ox_inventory and convert your database.

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

Qbox has multicharacter built into qbx_core.

If you want to keep using your own multicharacter resource, configure qbx_core accordingly. Otherwise you can disable or delete your old multicharacter resource.

Qbox has a queue system built into qbx_core.

If you want to keep using your own queue system, specify set qbx:enablequeue "false" inside your cfg file. Otherwise you can disable or delete your old queue system.

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.

Configure multijob/multigang

Qbox has a multijob/gang system built into core that cannot be disabled. By default, players may only be in one job & gang. This can be overriden by setting qbx:max_jobs_per_player and qbx:max_gangs_per_player in server.cfg. Do not use an external multijob/gang resource that isn't guaranteed by the developer to be Qbox compatible. Using incompatible multijobs or resources which modify core's database tables may lead to data corruption. First, double check that the player.citizenid column in your database has collation utf8mb4_unicode_ci. If not, change it. Then, run qbx_core.sql to create the new player_groups table. Start the server and type convertjobs into the txAdmin console once the server is running to populate the player_groups table. This needs to be done even if you don't already have a multijob/gang system.

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 })