forked from Simnation/Main
71 lines
2.7 KiB
Lua
71 lines
2.7 KiB
Lua
local QBCore = exports['qb-core']:GetCoreObject()
|
|
|
|
-- Open backpack inventory
|
|
RegisterNetEvent('backpack:server:openInventory', function(backpackStashId, backpackId, textureId)
|
|
local src = source
|
|
local Player = QBCore.Functions.GetPlayer(src)
|
|
|
|
if not Player then return end
|
|
|
|
-- Open the inventory
|
|
local backpackConfig = Config.Backpacks[backpackId]
|
|
if not backpackConfig then
|
|
print("Error: Backpack config not found for ID " .. backpackId)
|
|
return
|
|
end
|
|
|
|
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**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)
|
|
local src = source
|
|
local Player = QBCore.Functions.GetPlayer(src)
|
|
|
|
if backpackId and Config.Backpacks[backpackId] then
|
|
local backpackConfig = Config.Backpacks[backpackId]
|
|
|
|
TriggerClientEvent('ox_lib:notify', src, {
|
|
title = 'Backpack Info',
|
|
description = 'Type: ' .. backpackConfig.label ..
|
|
'\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)
|