All guides

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_librsg-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.progressCircleRSGCore.Functions.ProgressBar, ProgressCircle
lib.progressActive, lib.cancelProgressIsProgressActive, CancelProgress
lib.showTextUI, lib.hideTextUIexports['rsg-core']:DrawText, HideText
lib.requestModel, requestAnimDict, requestAnimSet, requestNamedPtfxAssetRSGCore.Functions.Request*
lib.locale() and locale()include @rsg-core/shared/locale.lua, then locale()
lib.requireinclude @rsg-core/shared/require.lua
lib.cron.newRSGCore.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.raycastRSGCore.Functions.RaycastCamera, Raycast
lib.getNearbyPeds, getNearbyVehicles, getNearbyObjectsRSGCore.Functions.GetNearbyPeds, GetNearbyVehicles, GetNearbyObjects
cache.pedPlayerPedId()
exports.ox_targetexports['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#

  1. In fxmanifest.lua, replace '@ox_lib/init.lua' in shared_scripts with '@rsg-core/shared/locale.lua'.
  2. Keep files { 'locales/*.json' }.
  3. 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#

  1. Search the resource for lib., ox_lib, cache. and ox_target, in code, fxmanifest.lua, config comments, README and docs.
  2. Replace each call with the equivalent above.
  3. Remove '@ox_lib/init.lua' from shared_scripts and 'ox_lib' from dependencies only when no references remain.
  4. Replace 'ox_target' with 'rsg-target' in dependencies, and change install steps to ensure rsg-target.
  5. Make sure every locale file keeps the same keys.
  6. Start the server and test each feature that used a replaced call.

Try GetPlayer, /bandana or weather. ↑↓ to move, Enter to open, Esc to close.