Integration

ESX Notify Integration

es_extended/client/functions.lua

function ESX.ShowNotification(message, notifyType, length)
    notifyType = notifyType or 'success'
    length = tonumber(length) or 5

    if IsResourceFound('esx_notify') then
        exports['esx_notify']:Notify(notifyType, length, message)
    elseif GetResourceState('frkn-uikit') == 'started' then
        exports['frkn-uikit']:Notify(notifyType, length, message)
    end
end

Esx Progressbar Integration

es_extended/client/functions.lua

function ESX.Progressbar(message, length, options)
    length = tonumber(length) or 5000
    options = options or {}

    if IsResourceFound('esx_progressbar') then
        return exports['esx_progressbar']:Progressbar(message, length, options)
    elseif GetResourceState('frkn-uikit') == 'started' then
        local progressModel = options.progressModel or "progressbar-1"
        local label = message or "Processing..."
        local duration = length or 5000
        local useWhileDead = options.useWhileDead or false
        local canCancel = options.canCancel ~= false
        local disableControls = options.disableControls or {
            disableMovement = false,
            disableCarMovement = false,
            disableMouse = false,
            disableCombat = true,
        }

        local anim = options.anim or {}
        local prop = options.prop or {}
        local propTwo = options.propTwo or {}
        local onFinish = options.onFinish
        local onCancel = options.onCancel

        exports['frkn-uikit']:Progressbar(progressModel, label, duration, useWhileDead, canCancel, disableControls, anim, prop, propTwo, onFinish, onCancel)
    else
        print(('[FRKN-UIKIT] Progressbar fallback: %s (%sms)'):format(message, length))
    end
end

Qb Notify Integration

qb-core/server/player.lua

function self.Functions.Notify(text, type, length)
    type = type or 'success'
    length = tonumber(length) or 5

    local src = self.PlayerData.source

    if GetResourceState('frkn-uikit') == 'started' then
        TriggerClientEvent('frkn-uikit:Notify', src, type, length, text)
    else
        TriggerClientEvent('QBCore:Notify', src, text, type, length)
    end
end

qb-core/client/functions.lua

function QBCore.Functions.Notify(text, texttype, length, icon)
    local notifyType = texttype or 'success'
    local duration = tonumber(length) or 5
    local message = ''

    if type(text) == 'table' then
        message = text.text or 'Notification'
    else
        message = text or 'Notification'
    end

    if GetResourceState('frkn-uikit') == 'started' then
        exports['frkn-uikit']:Notify(notifyType, duration, message)
    else
        local msg = {
            action = 'notify',
            type = texttype or 'primary',
            length = length or 5000,
        }

        if type(text) == 'table' then
            msg.text = text.text or 'Placeholder'
            msg.caption = text.caption or 'Placeholder'
        else
            msg.text = text
        end

        if icon then
            msg.icon = icon
        end

        SendNUIMessage(msg)
    end
end

Qb Progressbar Integration

qb-core/client/functions.lua

function QBCore.Functions.Progressbar(name, label, duration, useWhileDead, canCancel, disableControls, animation, prop, propTwo, onFinish, onCancel)
    if GetResourceState('frkn-uikit') ~= 'started' then
        error('frkn-uikit needs to be started in order for QBCore.Functions.Progressbar to work')
    end

    exports['frkn-uikit']:Progressbar(
        name or 'progressbar-1',
        label or 'Processing...',
        duration or 5000,
        useWhileDead or false,
        canCancel ~= false, 
        disableControls or {
            disableMovement = false,
            disableCarMovement = false,
            disableMouse = false,
            disableCombat = true
        },
        animation or {},
        prop or {},
        propTwo or {},
        function()
            if onFinish then
                onFinish()
            end
        end,
        function()
            if onCancel then
                onCancel()
            end
        end
    )
end

Qbox Notify Integration

qbx_core/server/functions.lua

---@see client/lua:Notify
function Notify(source, text, notifyType, duration, subTitle, notifyPosition, notifyStyle, notifyIcon, notifyIconColor)
    local title, description
    if type(text) == 'table' then
        title = text.text or 'Placeholder'
        description = text.caption or nil
    elseif subTitle then
        title = text
        description = subTitle
    else
        description = text
    end
    local position = notifyPosition or positionConfig
    TriggerClientEvent('frkn-uikit:Notify', source, notifyType, duration, description or title, notifyModel)
end

qbx_core/client/functions.lua

function Notify(text, notifyType, duration, subTitle, notifyPosition, notifyStyle, notifyIcon, notifyIconColor)
    local title, description
    if type(text) == 'table' then
        title = text.text or 'Placeholder'
        description = text.caption or nil
    elseif subTitle then
        title = text
        description = subTitle
    else
        description = text
    end
    local position = notifyPosition or positionConfig
    
    TriggerEvent('frkn-uikit:Notify', notifyType, duration, description or title, notifyModel)

end

Qbx Progressbar Integration

qbx_core/bridge/qb/client/functions.lua

function functions.Progressbar(_, label, duration, useWhileDead, canCancel, disableControls, animation, prop, _, onFinish, onCancel)
    exports["frkn-uikit"]:Progressbar(
        nil,
        label,
        duration,
        useWhileDead,
        canCancel,
        disableControls,
        {
            animDict = animation and animation.animDict or nil,
            anim = animation and animation.anim or nil,
            flags = animation and animation.flags or nil
        },
        prop,
        nil,
        onFinish,
        onCancel
    )
end

Ox lib Integration

ox_lib/resource/interface/client/notify.lua

function lib.notify(data)
    local notifyType = data.type or 'info'
    local duration = data.duration or 3000
    local message = data.description or data.title or "Notification"
    if GetResourceState('frkn-uikit') == 'started' then
        exports['frkn-uikit']:Notify(notifyType, duration, message)
    else
        local sound = settings.notification_audio and data.sound
        data.sound = nil
        data.position = data.position or settings.notification_position

        SendNUIMessage({
            action = 'notify',
            data = data
        })

        if not sound then return end

        if sound.bank then lib.requestAudioBank(sound.bank) end

        local soundId = GetSoundId()
        PlaySoundFrontend(soundId, sound.name, sound.set, true)
        ReleaseSoundId(soundId)

        if sound.bank then ReleaseNamedScriptAudioBank(sound.bank) end
    end
end

ox_lib/resource/interface/client/progressbar.lua

function lib.progressBar(data)
    if GetResourceState('frkn-uikit') == 'started' then
        local disable = data.disable or {}
        local anim = {}
        if data.anim then
            anim.animDict = data.anim.dict
            anim.anim = data.anim.clip
            anim.flags = data.anim.flag or 49
        end

        local result
        local finished = false

        exports['frkn-uikit']:Progressbar(
            "progressbar-1",
            data.label or "Processing...",
            data.duration or 5000,
            data.useWhileDead or false,
            data.canCancel or true,
            {
                disableMovement = disable.move or false,
                disableCarMovement = disable.car or false,
                disableMouse = disable.mouse or false,
                disableCombat = disable.combat or false,
            },
            anim,
            {},
            {},
            function() 
                result = true
                finished = true
            end,
            function() 
                result = false
                finished = true
            end
        )

        while not finished do
            Wait(0)
        end

        return result
    end

    while progress ~= nil do Wait(0) end
    if not interruptProgress(data) then
        SendNUIMessage({
            action = 'progress',
            data = {
                label = data.label,
                duration = data.duration
            }
        })
        return startProgress(data)
    end
end
function lib.progressCircle(data)
    if GetResourceState('frkn-uikit') == 'started' then
        local disable = data.disable or {}
        local anim = {}
        if data.anim then
            anim.animDict = data.anim.dict
            anim.anim = data.anim.clip
            anim.flags = data.anim.flag or 49
        end

        exports['frkn-uikit']:Progressbar(
            "progressbar-1",
            data.label or "Processing...",
            data.duration or 5000,
            data.useWhileDead or false,
            data.canCancel or true,
            {
                disableMovement = disable.move or false,
                disableCarMovement = disable.car or false,
                disableMouse = disable.mouse or false,
                disableCombat = disable.combat or false,
            },
            anim,
            {},
            {},
            function()
                if data.onFinish then data.onFinish() end
            end,
            function()
                if data.onCancel then data.onCancel() end
            end
        )
        return true
    end

    while progress ~= nil do Wait(0) end
    if not interruptProgress(data) then
        SendNUIMessage({
            action = 'circleProgress',
            data = {
                duration = data.duration,
                position = data.position,
                label = data.label
            }
        })
        return startProgress(data)
    end
end

ox_lib/resource/interface/client/textui.lua

function lib.showTextUI(text, options)
    if currentText == text then return end

    if not options then options = {} end
    options.text = text
    currentText = text

    local playerPed = PlayerPedId()
    local playerCoords = GetEntityCoords(playerPed)

    local coords = options.coords or playerCoords
    local distance = options.distance or 2.0

    exports['frkn-uikit']:openTextUi({
        title = options.title or '',
        text = text,
        style = options.style or 'default',
        keybind = options.keybind or 'E',
        color = options.color or 'white'
    }, coords, distance)

    isOpen = true
end

function lib.hideTextUI()
    if not isOpen then return end
    exports['frkn-uikit']:closeTextUi()
    isOpen = false
    currentText = nil
end

Last updated