Migrating from ox_lib and ox_target#
RSG Framework is moving the ox_lib features that scripts use into rsg-core, and targeting is handled by rsg-target. Most migrations are a rename. This guide lists what is available now. The authoritative list is the "ox_lib Migration Cheat Sheet" in the rsg-core documentation.
Equivalents#
| ox_lib | rsg-core |
|---|---|
lib.notify(data) | RSGCore.Functions.Notify(data) |
lib.callback.register (server) | RSGCore.Functions.CreateCallback(name, function(source, cb, ...) end) |
lib.callback.await (client) | RSGCore.Functions.AwaitCallback(name, timeout, ...) |
lib.callback.await (server to client) | RSGCore.Functions.AwaitClientCallback(name, source, timeout, ...) |
lib.progressBar, lib.progressCircle | RSGCore.Functions.ProgressBar, ProgressCircle |
lib.progressActive, lib.cancelProgress | IsProgressActive, CancelProgress |
lib.showTextUI, lib.hideTextUI | exports['rsg-core']:DrawText, HideText |
lib.requestModel, requestAnimDict, requestAnimSet, requestNamedPtfxAsset | RSGCore.Functions.Request* |
lib.locale() and locale() | include @rsg-core/shared/locale.lua, then locale() |
lib.require | include @rsg-core/shared/require.lua |
lib.cron.new | RSGCore.Functions.CreateCron |
lib.zones | @rsg-core/client/zones.lua (zones.sphere, zones.box, zones.poly) |
lib.points | @rsg-core/client/points.lua (points.new) |
lib.raycast | RSGCore.Functions.RaycastCamera, Raycast |
lib.getNearbyPeds, getNearbyVehicles, getNearbyObjects | RSGCore.Functions.GetNearbyPeds, GetNearbyVehicles, GetNearbyObjects |
cache.ped | PlayerPedId() |
exports.ox_target | exports['rsg-target'] |
rsg-core has no context menu, so there is no equivalent for lib.registerContext style menus yet. Where no equivalent exists, keep the ox_lib call until one does rather than guessing a name.
Callbacks answer with cb#
The one change that is not a pure rename: rsg-core handlers answer with cb(...) instead of return.
-- before (ox_lib)
lib.callback.register('res:server:getThing', function(source, arg)
return value
end)
local result = lib.callback.await('res:server:getThing', false, arg)
-- after (rsg-core)
RSGCore.Functions.CreateCallback('res:server:getThing', function(source, cb, arg)
cb(value)
end)
local result = RSGCore.Functions.AwaitCallback('res:server:getThing', nil, arg)
AwaitCallback returns nil on timeout (10 seconds by default) and must be called from a thread or event handler.
Notifications#
Client and server both use the rsg-core notification. The table is the same as lib.notify:
-- client
RSGCore.Functions.Notify({ title = 'Stable', description = 'Horse stored', type = 'success', duration = 5000, icon = 'fa-solid fa-horse' })
-- server
RSGCore.Functions.Notify(source, { title = 'Bank', description = 'Paid $5', type = 'success' })
Change any TriggerClientEvent('ox_lib:notify', ...) to RSGCore.Functions.Notify(source, data) or TriggerClientEvent('RSGCore:Client:Notify', source, data).
Locales#
- In
fxmanifest.lua, replace'@ox_lib/init.lua'inshared_scriptswith'@rsg-core/shared/locale.lua'. - Keep
files { 'locales/*.json' }. - Delete
lib.locale()calls.locale('key', ...)works directly.
The language comes from the rsg:locale convar, falling back to ox:locale, then en.
Targets#
-- before
exports.ox_target:addLocalEntity(ped, options)
-- after
exports['rsg-target']:addLocalEntity(ped, options)
The option fields (name, icon, label, distance, groups, items, canInteract, onSelect, event, serverEvent, export, command) are the same, so it is a rename of the export. See Add a target interaction.
Checklist for each resource#
- Search the resource for
lib.,ox_lib,cache.andox_target, in code,fxmanifest.lua, config comments, README and docs. - Replace each call with the equivalent above.
- Remove
'@ox_lib/init.lua'fromshared_scriptsand'ox_lib'fromdependenciesonly when no references remain. - Replace
'ox_target'with'rsg-target'independencies, and change install steps toensure rsg-target. - Make sure every locale file keeps the same keys.
- Start the server and test each feature that used a replaced call.