Drawtext

The utils.ui module contains some useful bridge functions for common NUI resources. You should choose your resource choice within server/config.lua.

You can add additional resources to cover also if required.

Functions

show_drawtext()

Shows chosen drawtext UI on screen.

Function

local function show_drawtext(options)
    if not options or not options.message then debug_log('err', 'Invalid drawtext data provided') return end

    if DRAWTEXT == 'boii_ui' then
        exports.boii_ui:show_drawtext(options.header, options.message, options.icon)
    elseif DRAWTEXT == 'ox_lib' then
        lib.showTextUI(options.message, { icon = options.icon })
    elseif DRAWTEXT == 'qb-core' then
        exports['qb-core']:DrawText(options.message)
    elseif DRAWTEXT == 'es_extended' then
        exports.es_extended:TextUI(options.message)
    elseif DRAWTEXT == 'okokTextUI' then
        exports['okokTextUI']:Open(options.message, 'lightgrey', 'left', true)
    elseif DRAWTEXT == 'custom' then
        --- Add custom implementation here
    else
        exports.boii_ui:show_drawtext(options.header, options.message, options.icon)
    end
end

exports('ui_show_drawtext', show_drawtext)
utils.ui.show_drawtext = show_drawtext

Example

--- Show drawtext.
utils.ui.show_drawtext({ 
    header = 'Test Drawtext',
    message = 'Test message..',
    icon = 'fa-solid fa-gear'
})

hide_drawtext()

Hides chosen drawtext UI on screen.

Function

local function hide_drawtext()
    if DRAWTEXT == 'boii_ui' then
        exports.boii_ui:hide_drawtext()
    elseif DRAWTEXT == 'ox_lib' then
        lib.hideTextUI()
    elseif DRAWTEXT == 'qb-core' then
        exports['qb-core']:HideText()
    elseif DRAWTEXT == 'es_extended' then
        exports.es_extended:HideUI()
    elseif DRAWTEXT == 'okokTextUI' then
        exports['okokTextUI']:Close()
    elseif DRAWTEXT == 'custom' then
        --- Add custom implementation here
    else
        exports.boii_ui:hide_drawtext()
    end
end

exports('ui_hide_drawtext', hide_drawtext)
utils.ui.hide_drawtext = hide_drawtext

Example

--- Hide drawtext.
utils.ui.hide_drawtext()

Last updated