forked from Simnation/Main
66 lines
2.4 KiB
Lua
66 lines
2.4 KiB
Lua
![]() |
local QBCore = exports['qb-core']:GetCoreObject()
|
||
|
|
||
|
-- Open backpack inventory
|
||
|
RegisterNetEvent('backpack:server:openInventory', function(backpackStashId, backpackId)
|
||
|
local src = source
|
||
|
local Player = QBCore.Functions.GetPlayer(src)
|
||
|
|
||
|
if not Player then return end
|
||
|
|
||
|
-- Open the inventory
|
||
|
local backpackConfig = Config.Backpacks[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**Backpack Type:** ' .. backpackConfig.label ..
|
||
|
'\n**Backpack 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)
|
||
|
|
||
|
-- Receive backpack info from client and show notification
|
||
|
RegisterNetEvent('backpack:server:showBackpackInfo', function(backpackId)
|
||
|
local src = source
|
||
|
local Player = QBCore.Functions.GetPlayer(src)
|
||
|
|
||
|
if backpackId then
|
||
|
local backpackConfig = Config.Backpacks[backpackId]
|
||
|
|
||
|
TriggerClientEvent('ox_lib:notify', src, {
|
||
|
title = 'Backpack Info',
|
||
|
description = 'Type: ' .. backpackConfig.label ..
|
||
|
'\nCapacity: ' .. (backpackConfig.maxweight / 1000) .. 'kg' ..
|
||
|
'\nSlots: ' .. backpackConfig.slots,
|
||
|
type = 'info',
|
||
|
duration = 5000
|
||
|
})
|
||
|
else
|
||
|
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)
|