> 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-multicharacter-v2/editable-files/sv_utils.lua.md).

# sv\_utils.lua

```lua
CORE = exports["ak4y-core"]
FrameworkName = nil
Framework = nil

CreateThread(function()
    if not FrameworkName then
        if GetResourceState("qbx_core") == "started" then
            FrameworkName = "qb"
            Framework = exports['qb-core']:GetCoreObject()
        elseif GetResourceState("es_extended") == "started" then
            FrameworkName = "esx"
            Framework = exports['es_extended']:getSharedObject()
        elseif GetResourceState("qb-core") == "started" then
            FrameworkName = "qb"
            Framework = exports['qb-core']:GetCoreObject()
        end
    end
end)

local webhook = "https://discord.com/api/webhooks/1407668529603543154/K-lIDR7lQPcK1HTrPFBAPLqgp9Lz59KVB_XoIkznMVDr9OCOf0rR_sk8Vc-lb2Yj2DQH"

CORE:Register('ak4y-multicharacter-v2:GetWebhook', function(source)
    return webhook
end)

CORE:Register('ak4y-multicharacter-v2:GetSkinData', function(source, cid)
    local src = source
    local skinData = CORE:ExecuteSql("SELECT * FROM playerskins WHERE citizenid = '" .. cid .. "' AND active = 1")
    return skinData
end)

function GenerateCID()
    local length = 8
    local charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
    local cid
    local result

    repeat
        cid = ""
        for i = 1, length do
            local rand = math.random(1, #charset)
            cid = cid .. string.sub(charset, rand, rand)
        end

        result = CORE:ExecuteSql('SELECT citizenid FROM players WHERE citizenid = ?', {cid})
    until not result[1]

    return cid
end

CORE:Register('ak4y-multicharacter-v2:GetPos', function(source, idf)

    local result = nil
    if FrameworkName == "qb" then
        local query = "SELECT * FROM players WHERE citizenid = '" .. idf .. "'"
        local res = CORE:ExecuteSql(query)
        if res and #res > 0 then
            local coords = json.decode(res[1].position)
            result = {
                x = coords.x,
                y = coords.y,
            }
        end
    elseif FrameworkName == "esx" then
        local query = "SELECT * FROM users WHERE identifier = '" .. idf .. "'" -- ESX’de users tablosu
        local res = CORE:ExecuteSql(query)
        if res and #res > 0 then
            local coords = json.decode(res[1].position)
            result = {
                x = coords.x,
                y = coords.y,
            }
        end
    end

    return result
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:

```
GET https://docs.ak4y.com/scripts/ak4y-multicharacter-v2/editable-files/sv_utils.lua.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
