This guide provides a complete step-by-step process to convert a QBCore-based script to work with Ox-related resources such as ox_core, ox_target, ox_inventory, and ox_lib.
Ensure you have the following Ox resources installed:
Replace QBCore functions with Ox equivalents.
local Player = QBCore.Functions.GetPlayer(source)
local identifier = Player.PlayerData.citizenid
local Player = exports.ox_core:GetPlayer(source)
local identifier = Player.charid
if Player.PlayerData.job.name == "police" then
-- Do something
end
if Player.getGroup() == "police" then
-- Do something
end
local cash = Player.Functions.GetMoney("cash")
local cash = Player.getAccount("cash").amount
Player.Functions.AddMoney("bank", 500)
Player.Functions.RemoveMoney("cash", 100)
Player.addAccountMoney("bank", 500)
Player.removeAccountMoney("cash", 100)
If your script uses qb-target
, update it to ox_target
.
exports['qb-target']:AddBoxZone("example", vector3(123.4, 567.8, 9.1), 1.5, 1.5, {
name = "example",
heading = 0,
debugPoly = false,
minZ = 8.9,
maxZ = 10.5,
}, {
options = {
{
type = "client",
event = "example:event",
icon = "fas fa-box",
label = "Interact",
}
},
distance = 2.0
})
exports['ox_target']:addBoxZone({
coords = vec3(123.4, 567.8, 9.1),
size = vec3(1.5, 1.5, 1.6),
rotation = 0,
debug = false,
options = {
{
event = "example:event",
icon = "fas fa-box",
label = "Interact",
}
}
})
If your script uses qb-menu
, switch to ox_lib
's context menu system.
exports['qb-menu']:openMenu({
{
header = "Main Menu",
isMenuHeader = true
},
{
header = "Option 1",
txt = "Do something",
params = {
event = "example:event"
}
}
})
lib.registerContext({
id = 'main_menu',
title = "Main Menu",
options = {
{
title = "Option 1",
description = "Do something",
event = "example:event"
}
}
})
lib.showContext("main_menu")
Player.Functions.AddItem("example_item", 1)
TriggerClientEvent("inventory:client:ItemBox", source, QBCore.Shared.Items["example_item"], "add")
exports['ox_inventory']:AddItem(source, "example_item", 1)
Player.Functions.RemoveItem("example_item", 1)
exports['ox_inventory']:RemoveItem(source, "example_item", 1)
local itemCount = Player.Functions.GetItemByName("example_item").amount
local itemCount = exports['ox_inventory']:GetItem(source, "example_item", false)
If your script uses QBCore.Functions.Notify
, switch to ox_lib
notifications.
QBCore.Functions.Notify("This is a message", "success")
lib.notify({
title = "Notification",
description = "This is a message",
type = "success"
})
This resource should help you understand how to make qbcore scripts compatible with ox_core. If you find or want to add qbcore or oxcore exports, open a pull request and make your changes there