local QBCoreF = exports['qb-core']:GetCoreObject()

QBCore = Config.CoreExport()
if Config.AdminCommand.Enabled then
    QBCore.Commands.Add(Config.AdminCommand.Name, Config.AdminCommand.Help, { {
        name = 'playerId', help = Config.AdminCommand.ArgHelp
    } }, true, function(source, args)
        if (args[1]) then
            TriggerClientEvent('hp_charcreator:openCreator', args[1], nil, true)
        end
    end, Config.AdminCommand.Group)
end

QBCore.Functions.CreateCallback('hp_charcreator:getCurrentSkin', function(source, cb)
    local Player = QBCore.Functions.GetPlayer(source)
    local result = MySQL.query.await('SELECT * FROM playerskins WHERE citizenid = ? AND active = ?',
        { Player.PlayerData.citizenid, 1 })
    if result[1] then
        cb(result[1].skin)
    end
end)

RegisterServerEvent("hp_multichar:playerConnected", function ()
    local src = source
    SetPlayerRoutingBucket(src, 0)
end)