2025-07-30 01:18:19 +02:00
|
|
|
local QBCore = exports['qb-core']:GetCoreObject()
|
|
|
|
|
|
|
|
-- Open backpack inventory
|
2025-07-30 01:33:52 +02:00
|
|
|
RegisterNetEvent('backpack:server:openInventory', function(backpackStashId, backpackId, textureId, gender)
|
2025-07-30 01:18:19 +02:00
|
|
|
local src = source
|
|
|
|
local Player = QBCore.Functions.GetPlayer(src)
|
|
|
|
|
|
|
|
if not Player then return end
|
|
|
|
|
|
|
|
-- Open the inventory
|
2025-07-30 01:33:52 +02:00
|
|
|
if not Config.Backpacks[gender] or not Config.Backpacks[gender][backpackId] then
|
|
|
|
print("Error: Backpack config not found for Gender=" .. gender .. ", ID=" .. backpackId)
|
2025-07-30 01:31:07 +02:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2025-07-30 01:33:52 +02:00
|
|
|
local backpackConfig = Config.Backpacks[gender][backpackId]
|
|
|
|
|
2025-07-30 01:18:19 +02:00
|
|
|
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 ..
|
2025-07-30 01:33:52 +02:00
|
|
|
'\n**Gender:** ' .. (gender == 0 and "Male" or "Female") ..
|
2025-07-30 01:18:19 +02:00
|
|
|
'\n**Backpack Type:** ' .. backpackConfig.label ..
|
2025-07-30 01:31:07 +02:00
|
|
|
'\n**Backpack ID:** ' .. backpackId ..
|
|
|
|
'\n**Texture ID:** ' .. textureId ..
|
|
|
|
'\n**Stash ID:** ' .. backpackStashId)
|
2025-07-30 01:18:19 +02:00
|
|
|
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)
|
|
|
|
|
2025-07-30 01:31:07 +02:00
|
|
|
-- 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)
|
|
|
|
|
2025-07-30 01:18:19 +02:00
|
|
|
-- Receive backpack info from client and show notification
|
2025-07-30 01:33:52 +02:00
|
|
|
RegisterNetEvent('backpack:server:showBackpackInfo', function(backpackId, textureId, gender)
|
2025-07-30 01:18:19 +02:00
|
|
|
local src = source
|
|
|
|
local Player = QBCore.Functions.GetPlayer(src)
|
|
|
|
|
2025-07-30 01:33:52 +02:00
|
|
|
if backpackId and Config.Backpacks[gender] and Config.Backpacks[gender][backpackId] then
|
|
|
|
local backpackConfig = Config.Backpacks[gender][backpackId]
|
2025-07-30 01:18:19 +02:00
|
|
|
|
|
|
|
TriggerClientEvent('ox_lib:notify', src, {
|
|
|
|
title = 'Backpack Info',
|
|
|
|
description = 'Type: ' .. backpackConfig.label ..
|
2025-07-30 01:33:52 +02:00
|
|
|
'\nGender: ' .. (gender == 0 and "Male" or "Female") ..
|
2025-07-30 01:31:07 +02:00
|
|
|
'\nDrawable ID: ' .. backpackId ..
|
|
|
|
'\nTexture ID: ' .. textureId ..
|
2025-07-30 01:18:19 +02:00
|
|
|
'\nCapacity: ' .. (backpackConfig.maxweight / 1000) .. 'kg' ..
|
|
|
|
'\nSlots: ' .. backpackConfig.slots,
|
|
|
|
type = 'info',
|
|
|
|
duration = 5000
|
|
|
|
})
|
|
|
|
else
|
|
|
|
TriggerClientEvent('ox_lib:notify', src, Config.Notifications.noBackpack)
|
|
|
|
end
|
|
|
|
end)
|