Integración opcional con ox_lib TextUI

Esta integración redirige al HUD las interacciones de una sola tecla E que pasan por lib.showTextUI. Lo que no encaje sigue mostrándose con el TextUI de ox_lib.

server.cfg

ensure ox_lib
ensure jex_interactions

# Los recursos que llamen a lib.showTextUI van por debajo de esta linea.
ensure my_resource

jex_interactions/config.lua

Config.InterceptTextUI = true

Abre ox_lib/resource/interface/client/textui.lua. Conserva sus anotaciones de tipos y sustituye el estado del TextUI y las implementaciones de lib.showTextUI, lib.hideTextUI y lib.isTextUIOpen por este bloque:

ox_lib/resource/interface/client/textui.lua

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)

Reinicia el servidor entero después de editar ox_lib. Con la intercepción desactivada, con el HUD parado o con un aviso no compatible, ox_lib sigue mostrando su TextUI de siempre con sus opciones.