> 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-transport/editable-files/cl_utils.lua.md).

# cl\_utils.lua

```lua
function Draw3DText(data)
    local text = data.text
    local x, y, z = data.coords.x, data.coords.y, data.coords.z

    local onScreen, screenX, screenY = World3dToScreen2d(x, y, z)
    if onScreen then
        local dist = #(GetGameplayCamCoord() - vector3(x, y, z))
        SendNUIMessage({
            action = "showInteract",
            label = text,
            keydisplay = data.keydisplay,
            x = screenX * 100,
            y = screenY * 100
        })
        visible = true
        lastDrawTick = GetGameTimer()
    else
        SendNUIMessage({ action = "hideInteract" })
    end
end

function GiveVehicleKey(plate, vehicle)
    TriggerServerEvent('qb-vehiclekeys:server:AcquireVehicleKeys', plate)
end

CreateThread(function()
    blipOpen = true
    if Config.StartJob.blip then
        JobBlip = AddBlipForCoord(Config.StartJob.coords.x, Config.StartJob.coords.y)
        SetBlipSprite(JobBlip, Config.StartJob.blip.sprite)
        SetBlipDisplay(JobBlip, 2)
        SetBlipScale(JobBlip, Config.StartJob.blip.scale)
        SetBlipColour(JobBlip, Config.StartJob.blip.color)
        SetBlipAsShortRange(JobBlip, true)
        BeginTextCommandSetBlipName("STRING")
        AddTextComponentString(Config.StartJob.blip.name)
        EndTextCommandSetBlipName(JobBlip)
    end
    RequestModel(Config.StartJob.ped)
    while not HasModelLoaded(Config.StartJob.ped) do Wait(10) end
    workerPed = CreatePed(0, Config.StartJob.ped, Config.StartJob.coords.x, Config.StartJob.coords.y, Config.StartJob.coords.z - 0.95, Config.StartJob.coords.w, false, false)
    FreezeEntityPosition(workerPed, true)
	SetEntityHeading(workerPed, Config.StartJob.coords.w)
	SetEntityInvincible(workerPed, true)
	SetBlockingOfNonTemporaryEvents(workerPed, true)
	TaskStartScenarioInPlace(workerPed, "WORLD_HUMAN_CLIPBOARD", 0, true)
    if Config.Interaction == "drawtext" then
        local sleep = 1000
        while true do
            if GetDistanceBetweenCoords(GetEntityCoords(PlayerPedId()), Config.StartJob.coords.x, Config.StartJob.coords.y, Config.StartJob.coords.z, true) < 30.0 then
                sleep = 1
            else
                sleep = 1000
            end
            if GetDistanceBetweenCoords(GetEntityCoords(PlayerPedId()), Config.StartJob.coords.x, Config.StartJob.coords.y, Config.StartJob.coords.z, true) < 2.0 then
                Draw3DText({
                    text = Config.locales[Config.Locale].game.access_menu,
                    coords = vec3(Config.StartJob.coords.x, Config.StartJob.coords.y, Config.StartJob.coords.z),
                })
                if IsControlJustReleased(0, 38) then
                    TriggerEvent('ak4y-transport:OpenMenu')
                end
            end
            Wait(sleep)
        end
    elseif Config.Interaction == "target" then
        exports["ak4y-core"]:AddEntityToTargeting(
            workerPed,
            Config.locales[Config.Locale].game.access_menu,
            "ak4y-transport:OpenMenu", nil, nil, 2.5
        )
    end
end)

function OnBoxAttach()
    TriggerServerEvent('ak4y-transport:AddTaskCount', 5, 1)
end

function OnBoxDetach()
    TriggerServerEvent('ak4y-transport:AddTaskCount', 6, 1)
end

function OnTieRope()
    TriggerServerEvent('ak4y-transport:AddTaskCount', 8, 1)
end

function UntieRope()
    TriggerServerEvent('ak4y-transport:AddTaskCount', 7, 1)
end

function DeliverVehicle(vehiclemodel)
    if vehiclemodel == "italirsx" then
        TriggerServerEvent('ak4y-transport:AddTaskCount', 3, 1)
    end

    TriggerServerEvent('ak4y-transport:AddTaskCount', 10, 1)
end

function DeliverItemInBox(itemModel)
    if itemModel == "ch_prop_ch_generator_01a" then
        TriggerServerEvent('ak4y-transport:AddTaskCount', 2, 1)
    end
end

function AddFinishJob(playersCount, jobType)
    if playersCount >= 2 then
        TriggerServerEvent('ak4y-transport:AddTaskCount', 1, 1)
    end

    if playersCount >= 3 then
        TriggerServerEvent('ak4y-transport:AddTaskCount', 9, 1)
    end

    TriggerServerEvent('ak4y-transport:AddTaskCount', 4, 1)
end

function NotifyFunc(text)
    exports["ak4y-core"]:NotifyViaFramework(text)
end

-- Stages = {
--     ["pallet"] = {
--         [1] = {
--             header = "Box Loading",
--             desc = "put boxes etc. etc.",
--             current = 0,
--             need = 6,
--         },
--         [2] = {
--             header = "deliver to coord",
--             desc = "deliver to coord etc.",
--             current = 0,
--             need = 1,
--         },
--         [3] = {
--             header = "Box Unloading",
--             desc = "unload boxes etc. etc.",
--             current = 0,
--             need = 6,
--         },
--         [4] = {
--             header = "Deliver the items",
--             desc = "deliver items etc. etc.",
--             current = 0,
--             need = 6,
--         },
--     },
--     ["vehicle"] = {
--         [1] = {
--             header = "vehicle Loading",
--             desc = "vehicle load etc. etc.",
--             current = 0,
--             need = 2,
--         },
--         [2] = {
--             header = "deliver to coord",
--             desc = "deliver to coord etc.",
--             current = 0,
--             need = 1,
--         },
--         [3] = {
--             header = "deliver vehicle",
--             desc = "vehicle deliver etc. etc.",
--             current = 0,
--             need = 2,
--         },
--         [4] = {
--             header = "deliver to trailer",
--             desc = "deliver trailer to coord etc.",
--             current = 0,
--             need = 1,
--         },
--     }
-- }
```


---

# 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-transport/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.
