FiveM Docs
Guides

Using ox_lib with ESX Legacy

Use ox_lib with ESX Legacy for notifications, progress bars and context menus, with working fxmanifest imports and fixes for global lib is nil and startup issues.

ox_lib can be used alongside ESX Legacy, providing notifications, progress indicators, context menus, callbacks and other reusable client-side utilities. It does not replace the official ESX esx_lib resource.

Install ox_lib alongside ESX

Download a maintained release from Community Ox or the appropriate maintained repository for your installation. The library must be built and include its web assets.

server.cfg
ensure oxmysql
ensure ox_lib
ensure esx_lib
ensure es_extended
ensure my_resource

Add the initialization script before your own resource files:

fxmanifest.lua
fx_version 'cerulean'
game 'gta5'

shared_scripts {
    '@ox_lib/init.lua',
    '@es_extended/imports.lua',
}

client_script 'client.lua'
server_script 'server.lua'
dependencies { 'ox_lib', 'es_extended' }

Use lib for ox_lib APIs and ESX for ESX APIs. They are separate global objects supplied by their respective imports.

Notifications from client and server

On the client:

client.lua
lib.notify({
    title = 'Delivery completed',
    description = 'Your package was delivered.',
    type = 'success',
    duration = 3500,
})

On the server, target a specific player:

server.lua
RegisterCommand('testnotify', function(source)
    if source == 0 then return end

    TriggerClientEvent('ox_lib:notify', source, {
        title = 'Test notification',
        description = 'ox_lib is available on your client.',
        type = 'inform',
    })
end, false)

Don't accidentally send a client-only notification to all players. The normal ESX equivalents, ESX.ShowNotification on the client and xPlayer.showNotification on the server, are also valid without ox_lib.

Progress bars and cancellation

The following client-side call returns true on successful completion and false when cancelled. Treat it as a user interface action, not proof that the player earned an item.

client.lua
RegisterCommand('testprogress', function()
    local completed = lib.progressBar({
        duration = 3000,
        label = 'Preparing package',
        canCancel = true,
        useWhileDead = false,
        disable = {
            move = true,
            car = true,
            combat = true,
        },
    })

    if completed then
        lib.notify({ description = 'Animation finished', type = 'success' })
    else
        lib.notify({ description = 'Cancelled', type = 'warning' })
    end
end, false)

lib.progressCircle accepts comparable options and presents a circular indicator. Any money, item or job change must be independently authorized by the server.

Context menus and callbacks

For context menus use lib.registerContext and lib.showContext. For asynchronous client/server interactions, consult the ox_lib callback module. These APIs have different signatures from the native ESX menu and callback APIs, so do not mix their function names.

Use the ox_lib documentation for the exact API signatures. If an existing ESX addon already uses esx_context or esx_progressbar, you do not have to replace it just to use ox_lib in a different script.

Troubleshooting

ErrorFix
attempt to index a nil value (global 'lib')Import @ox_lib/init.lua before your scripts
No such export from ox_libCheck installation, build assets and startup
Notification works in client but not serverUse TriggerClientEvent('ox_lib:notify', source, data)
lib.progressBar always cancelsReview player state and your cancellation/disable options
ESX functions are nilImport @es_extended/imports.lua separately

Frequently asked questions

Independent documentation

esx-fivem.com is a community project and is not affiliated with the ESX Framework team. Facts on this page were checked against the upstream source. Official resources: docs.esx-framework.org and github.com/esx-framework.

Last updated on

On this page