> For the complete documentation index, see [llms.txt](https://docs.ak4y.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ak4y.com/scripts/ak4y-boxing/editable-files/cl_utils.lua.md).

# cl\_utils.lua

```lua
Framework = nil
loadEvent = "QBCore:Client:OnPlayerLoaded"

CreateThread(function()
    if not Framework then
        if GetResourceState("qbx_core") == "started" then
            Framework = "qb"
        elseif GetResourceState("es_extended") == "started" then
            Framework = "esx"
        elseif GetResourceState("qb-core") == "started" then
            Framework = "qb"
        end
    end
end)

CreateThread(function()
    if Framework == "qb" then
        loadEvent = "QBCore:Client:OnPlayerLoaded"
    elseif Framework == "esx" then
        loadEvent = 'esx:playerLoaded'
    elseif Framework == "oldEsx" then
        loadEvent = 'esx:playerLoaded'
    end

    RegisterNetEvent(loadEvent, function()

    end)
end)

function ReviveFunc()
    Wait(300)
    ExecuteCommand('revive')
    ExecuteCommand('reloadskin')
    Wait(300)
    FreezeEntityPosition(PlayerPedId(), false)
    setGloveLoc()
end

CreateThread(function()
    for k,v in pairs(Config.BoxArenas) do
        RequestModel(v.npcModel)
        while not HasModelLoaded(v.npcModel) do Wait(10) end
        workerPed = CreatePed(0, v.npcModel, v.npcCoords.x,  v.npcCoords.y,  v.npcCoords.z - 0.95,  v.npcCoords.w, false, false)
        FreezeEntityPosition(workerPed, true)
	    SetEntityHeading(workerPed, v.npcCoords.w)
	    SetEntityInvincible(workerPed, true)
	    SetBlockingOfNonTemporaryEvents(workerPed, true)
	    TaskStartScenarioInPlace(workerPed, "WORLD_HUMAN_CLIPBOARD", 0, true)

        if v.blip then
            local blip = AddBlipForCoord(v.centerCoord)
            SetBlipSprite(blip, v.blip.sprite)
            SetBlipDisplay(blip, 2)
            SetBlipScale(blip, v.blip.scale)
            SetBlipColour(blip, v.blip.color)
            SetBlipAsShortRange(blip, true)
            BeginTextCommandSetBlipName("STRING")
            AddTextComponentString(v.blip.name)
            EndTextCommandSetBlipName(blip)
        end
    end

    local sleepValue = 1000

    while true do
        Wait(sleepValue)
        local isCloseBoxArea = false
        for k,v in pairs(Config.BoxArenas) do
            if GetDistanceBetweenCoords(GetEntityCoords(PlayerPedId()), vec3(v.npcCoords.x, v.npcCoords.y, v.npcCoords.z), true) < 30 then
                isCloseBoxArea = k
            end
        end
        if isCloseBoxArea then
            sleepValue = 1
            local npcCoord = Config.BoxArenas[isCloseBoxArea].npcCoords
            if GetDistanceBetweenCoords(GetEntityCoords(PlayerPedId()), vec3(npcCoord.x, npcCoord.y, npcCoord.z), true) < 5 then
                Draw3DText({
                    text = "[E] Open Boxing",
                    coords = npcCoord,
                })
                if IsControlJustReleased(0, 38) then
                    TriggerEvent('ak4y-boxing:OpenMenu', isCloseBoxArea)
                end
            end
        else
            sleepValue = 1000
        end
    end
end)

function Draw3DText(data)
    local text = data.text
    local x = data.coords.x
    local y = data.coords.y
    local z = data.coords.z
    SetTextScale(0.35, 0.35)
    SetTextFont(4)
    SetTextProportional(1)
    SetTextColour(255, 255, 255, 215)
    SetTextEntry("STRING")
    SetTextCentre(true)
    AddTextComponentString(text)
    SetDrawOrigin(x,y,z, 0)
    DrawText(0.0, 0.0)
    local factor = (string.len(text)) / 370
    DrawRect(0.0, 0.0+0.0125, 0.017+ factor, 0.03, 0, 0, 0, 75)
    ClearDrawOrigin()
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.ak4y.com/scripts/ak4y-boxing/editable-files/cl_utils.lua.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.
