Optional ox_lib TextUI integration
This integration redirects compatible single-key E interactions from lib.showTextUI to the HUD. Prompts that are not compatible keep using the native ox_lib TextUI.
ensure ox_lib
ensure jex_interactions
# Resources that call lib.showTextUI start below this line.
ensure my_resource
Config.InterceptTextUI = true
Open ox_lib/resource/interface/client/textui.lua. Keep its type annotations, and replace the TextUI state plus the lib.showTextUI, lib.hideTextUI and lib.isTextUIOpen implementations with this compatibility block:
local isOpen = false
local currentText
local usingHud = false
local HUD = 'jex_interactions'
local function hideNative()
if not isOpen then return end
SendNUIMessage({ action = 'textUiHide' })
isOpen = false
end
local function releaseHud()
if GetResourceState(HUD) == 'started' then
pcall(function()
exports[HUD]:releaseTextUI()
end)
end
usingHud = false
end
---@param text string
---@param options? TextUIOptions
function lib.showTextUI(text, options)
if currentText == text then return end
currentText = text
usingHud = false
if GetResourceState(HUD) == 'started' then
local ok, taken = pcall(function()
return exports[HUD]:consumeTextUI(text)
end)
if ok and taken then
hideNative()
usingHud = true
return
end
end
if not options then options = {} end
options.text = text
SendNUIMessage({
action = 'textUi',
data = options
})
isOpen = true
end
function lib.hideTextUI()
releaseHud()
hideNative()
currentText = nil
end
---@return boolean, string | nil
function lib.isTextUIOpen()
return (isOpen or usingHud), currentText
end
AddEventHandler('onClientResourceStop', function(resource)
if resource ~= HUD or not usingHud then return end
usingHud = false
local text = currentText
currentText = nil
if text then lib.showTextUI(text) end
end)
Restart the entire server after editing ox_lib. When interception is disabled, the HUD is unavailable or a prompt is unsupported, ox_lib keeps displaying its original TextUI with its normal options.