> For the complete documentation index, see [llms.txt](https://docs.okokscripts.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.okokscripts.io/scripts/okoktextui/snippets.md).

# Snippets

### QBCore DrawText to okokTextUI

Change the following code in **qb-core/client/drawtext.lua**:

```lua
local function hideText()
    exports['okokTextUI']:Close()
end

local function drawText(text, _)
    exports['okokTextUI']:Open(text, 'darkblue', 'right')
end

-- local function changeText(text, position) -- Can't use
--     if type(position) ~= "string" then position = "left" end

--     SendNUIMessage({
--         action = 'CHANGE_TEXT',
--         data = {
--             text = text,
--             position = position
--         }
--     })
-- end

local function keyPressed()
    CreateThread(function() -- Can't use
        --[[ SendNUIMessage({
            action = 'KEY_PRESSED',
        }) ]]
        --Wait(500)
        hideText()
    end)
end

RegisterNetEvent('qb-core:client:DrawText', function(text, position)
    drawText(text, position)
end)

-- RegisterNetEvent('qb-core:client:ChangeText', function(text, position) -- Can't use
--     changeText(text, position)
-- end)

RegisterNetEvent('qb-core:client:HideText', function()
    hideText()
end)

-- RegisterNetEvent('qb-core:client:KeyPressed', function() -- Can't use
--     keyPressed()
-- end)

exports('DrawText', drawText)
--exports('ChangeText', changeText) -- Can't use
exports('HideText', hideText)
exports('KeyPressed', keyPressed) -- Can't use
```

### **ESX.TextUI to okokTextUI**

Navigate to **es\_extended/client/functions.lua** and edit the following functions:

**ESX.TextUI**

```lua
function ESX.TextUI(message, type)
    if type == 'info' then
        type = 'darkblue' -- or `lightblue`
    elseif type == 'success' then
        type = 'darkgreen' -- or 'lightgreen'
    elseif type == 'error' then
        type = 'darkred' -- or 'lightred'
    else 
        type = 'darkgrey' -- or 'lightgrey'
    end

    if GetResourceState('okokTextUI') ~= 'missing' then
        exports['okokTextUI']:Open(message, type, "left")
    else
        print('[^1ERROR^7] ^5okokTextUI^7 is Missing!')
    end
end
```

**ESX.HideUI**

```lua
function ESX.HideUI()
    if GetResourceState("okokTextUI") ~= "missing" then
        exports["okokTextUI"]:Close()
    else 
        print("[^1ERROR^7] ^5okokTextUI^7 is Missing!")
    end
end
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.okokscripts.io/scripts/okoktextui/snippets.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
