ox_lib: a common UI toolbox
So far you have built things the long way so you could see how they work. Now it is time to use the toolbox most modern FiveM servers reach for. ox_lib gives you ready-made pop-ups, menus, dialogs, and progress bars so you can focus on script logic instead of rebuilding UI every time. It is a community library from the Overextended team, not an official Cfx.re resource, but it is so widely used that knowing it is part of the job.
Build it
Confirm ox_lib is installed and started
Your resource borrows the lib global from ox_lib, so ox_lib has to be running before your resource starts. In server.cfg, ox_lib must be ensured above your lesson resource:
ensure ox_lib
ensure qu_ox_lib_notifications_ui
If you do not have ox_lib yet, download the latest release from the CommunityOx GitHub (github.com/CommunityOx/ox_lib/releases) and drop the ox_lib folder into resources. Do not rename it: the @ox_lib/init.lua path in the next step depends on the folder being called exactly ox_lib.
Make the resource folder
Inside your server's resources folder, create this folder:
resources/qu_ox_lib_notifications_ui
Create the files
Create this exact file layout:
resources/qu_ox_lib_notifications_ui/
fxmanifest.lua
client.lua
Write fxmanifest.lua
Open fxmanifest.lua and paste this:
fx_version 'cerulean'
game 'gta5'
shared_script '@ox_lib/init.lua'
client_script 'client.lua'
dependencies {
'ox_lib'
}
Older guides write the dependency as dependency 'ox_lib' (singular). That form is still tolerated, but the documented modern form is the plural table dependencies { 'ox_lib' }, so that is what you use here.
Write the lesson code
Open client.lua and paste this:
lib.registerContext({
id = 'qu_ox_lib_notifications_ui_menu',
title = 'qu_ox_lib_notifications_ui',
options = {
{ title = 'Ask name', event = 'qu_ox_lib_notifications_ui:ask' }
}
})
RegisterCommand('oxdemo', function()
lib.notify({
title = 'qu_ox_lib_notifications_ui',
description = 'Notification works',
type = 'success'
})
lib.showContext('qu_ox_lib_notifications_ui_menu')
end, false)
AddEventHandler('qu_ox_lib_notifications_ui:ask', function()
local input = lib.inputDialog('Save a name', { 'Name' })
if not input then return end
lib.progressCircle({ duration = 1000, label = 'Saving' })
print('[qu_ox_lib_notifications_ui] saved ' .. input[1])
end)
Start and test it
With the two ensure lines from Step 1 already in server.cfg, save the file, then run:
restart qu_ox_lib_notifications_ui
Join the server, then type this in the chat box (press T):
/oxdemo
A green notification appears, a menu opens with one option, choosing it asks for a name, a progress circle runs for one second, and then the line below prints to your F8 client console. Type Mike when the dialog asks.
Keep reading the full lesson
Sign in to start, then unlock every step of this lesson and the full FiveM School with a membership.
- How it works
- If something went wrong
- What you can do now
- Try it yourself
The remainder of ox_lib: notifications and UI is available to FiveM School members.