local QBCore = exports['qb-core']:GetCoreObject() -- Open backpack inventory RegisterNetEvent('backpack:server:openInventory', function(backpackStashId, backpackId, textureId, gender) local src = source local Player = QBCore.Functions.GetPlayer(src) if not Player then return end -- Open the inventory if not Config.Backpacks[gender] or not Config.Backpacks[gender][backpackId] then print("Error: Backpack config not found for Gender=" .. gender .. ", ID=" .. backpackId) return end local backpackConfig = Config.Backpacks[gender][backpackId] exports["tgiann-inventory"]:OpenInventory(src, "stash", backpackStashId, { maxweight = backpackConfig.maxweight, slots = backpackConfig.slots, label = backpackConfig.label }) -- Send success notification TriggerClientEvent('ox_lib:notify', src, Config.Notifications.backpackOpened) -- Log the backpack opening if enabled if Config.Logs.enabled then TriggerEvent('qb-log:server:CreateLog', Config.Logs.webhookName, Config.Logs.openTitle, Config.Logs.openColor, '**Player:** ' .. Player.PlayerData.name .. '\n**Gender:** ' .. (gender == 0 and "Male" or "Female") .. '\n**Backpack Type:** ' .. backpackConfig.label .. '\n**Backpack ID:** ' .. backpackId .. '\n**Texture ID:** ' .. textureId .. '\n**Stash ID:** ' .. backpackStashId) end end) -- Add command to check backpack info QBCore.Commands.Add('checkbackpack', 'Check your backpack info', {}, false, function(source, args) TriggerClientEvent('backpack:client:checkBackpack', source) end) -- Add command to list all clothing (for debugging) QBCore.Commands.Add('listclothing', 'List all clothing components (Debug)', {}, false, function(source, args) TriggerClientEvent('backpack:client:listClothing', source) end) -- Receive backpack info from client and show notification RegisterNetEvent('backpack:server:showBackpackInfo', function(backpackId, textureId, gender) local src = source local Player = QBCore.Functions.GetPlayer(src) if backpackId and Config.Backpacks[gender] and Config.Backpacks[gender][backpackId] then local backpackConfig = Config.Backpacks[gender][backpackId] TriggerClientEvent('ox_lib:notify', src, { title = 'Backpack Info', description = 'Type: ' .. backpackConfig.label .. '\nGender: ' .. (gender == 0 and "Male" or "Female") .. '\nDrawable ID: ' .. backpackId .. '\nTexture ID: ' .. textureId .. '\nCapacity: ' .. (backpackConfig.maxweight / 1000) .. 'kg' .. '\nSlots: ' .. backpackConfig.slots, type = 'info', duration = 5000 }) else TriggerClientEvent('ox_lib:notify', src, Config.Notifications.noBackpack) end end)