ed
This commit is contained in:
parent
0905e09ac9
commit
98a52d34f5
4 changed files with 125 additions and 30 deletions
|
@ -1,7 +1,7 @@
|
|||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
|
||||
-- Open backpack inventory
|
||||
RegisterNetEvent('backpack:server:openInventory', function(backpackStashId, backpackId)
|
||||
RegisterNetEvent('backpack:server:openInventory', function(backpackStashId, backpackId, textureId)
|
||||
local src = source
|
||||
local Player = QBCore.Functions.GetPlayer(src)
|
||||
|
||||
|
@ -9,6 +9,11 @@ RegisterNetEvent('backpack:server:openInventory', function(backpackStashId, back
|
|||
|
||||
-- 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,
|
||||
|
@ -26,27 +31,35 @@ RegisterNetEvent('backpack:server:openInventory', function(backpackStashId, back
|
|||
Config.Logs.openColor,
|
||||
'**Player:** ' .. Player.PlayerData.name ..
|
||||
'\n**Backpack Type:** ' .. backpackConfig.label ..
|
||||
'\n**Backpack ID:** ' .. backpackStashId)
|
||||
'\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)
|
||||
-- Get the player's current bag drawable
|
||||
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)
|
||||
RegisterNetEvent('backpack:server:showBackpackInfo', function(backpackId, textureId)
|
||||
local src = source
|
||||
local Player = QBCore.Functions.GetPlayer(src)
|
||||
|
||||
if backpackId then
|
||||
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',
|
||||
|
@ -56,10 +69,3 @@ RegisterNetEvent('backpack:server:showBackpackInfo', function(backpackId)
|
|||
TriggerClientEvent('ox_lib:notify', src, Config.Notifications.noBackpack)
|
||||
end
|
||||
end)
|
||||
|
||||
-- Add this event handler for the client to send backpack info
|
||||
RegisterNetEvent('backpack:client:checkBackpack', function()
|
||||
local src = source
|
||||
local backpackId = CheckForBackpack()
|
||||
TriggerServerEvent('backpack:server:showBackpackInfo', backpackId)
|
||||
end)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue