From 135f0e163e55266556d9d6f2fec392daa2b807d9 Mon Sep 17 00:00:00 2001 From: Nordi98 Date: Wed, 30 Jul 2025 01:18:19 +0200 Subject: [PATCH] ed --- .../[inventory]/nord_backpack/client.lua | 76 +++++++++++++++++++ .../[inventory]/nord_backpack/config.lua | 57 ++++++++++++++ .../[inventory]/nord_backpack/fxmanifest.lua | 26 +++++++ .../[inventory]/nord_backpack/server.lua | 65 ++++++++++++++++ .../tgiann-inventory/items/items.lua | 2 +- 5 files changed, 225 insertions(+), 1 deletion(-) create mode 100644 resources/[inventory]/nord_backpack/client.lua create mode 100644 resources/[inventory]/nord_backpack/config.lua create mode 100644 resources/[inventory]/nord_backpack/fxmanifest.lua create mode 100644 resources/[inventory]/nord_backpack/server.lua diff --git a/resources/[inventory]/nord_backpack/client.lua b/resources/[inventory]/nord_backpack/client.lua new file mode 100644 index 000000000..14f786851 --- /dev/null +++ b/resources/[inventory]/nord_backpack/client.lua @@ -0,0 +1,76 @@ +local QBCore = exports['qb-core']:GetCoreObject() + +-- Check if player has a backpack equipped +function CheckForBackpack() + local ped = PlayerPedId() + + -- Get the current bag drawable ID (component 5 is the bag slot) + local currentBag = GetPedDrawableVariation(ped, 5) + + -- Check if this bag ID is in our config + if Config.Backpacks[currentBag] then + return currentBag + end + + return nil +end + +-- Open backpack inventory command +RegisterCommand('openbackpack', function() + local backpackId = CheckForBackpack() + + if backpackId then + local citizenId = QBCore.Functions.GetPlayerData().citizenid + local backpackStashId = "backpack_" .. citizenId .. "_" .. backpackId + + TriggerServerEvent('backpack:server:openInventory', backpackStashId, backpackId) + else + lib.notify(Config.Notifications.noBackpack) + end +end, false) + +-- Register key binding +RegisterKeyMapping('openbackpack', 'Open Backpack Inventory', 'keyboard', Config.BackpackKey) + +-- Listen for inventory open event to check if we should show backpack +RegisterNetEvent('inventory:client:OpenInventory', function() + -- Small delay to let the main inventory open first + Citizen.Wait(100) + + -- Check if player has a backpack and automatically show the backpack tab + local backpackId = CheckForBackpack() + if backpackId then + local citizenId = QBCore.Functions.GetPlayerData().citizenid + local backpackStashId = "backpack_" .. citizenId .. "_" .. backpackId + + TriggerServerEvent('backpack:server:openInventory', backpackStashId, backpackId) + end +end) + +-- Monitor for clothing changes to update backpack status +Citizen.CreateThread(function() + local lastBackpack = nil + + while true do + Citizen.Wait(1000) -- Check every second + + local currentBackpack = CheckForBackpack() + + -- If backpack status changed + if currentBackpack ~= lastBackpack then + lastBackpack = currentBackpack + + -- If player removed a backpack, we could add additional logic here + if not currentBackpack then + -- Player removed backpack + else + -- Player equipped backpack + end + end + end +end) + +-- Initialize when player loads +RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function() + -- Nothing needed here, backpack will be checked when inventory is opened +end) diff --git a/resources/[inventory]/nord_backpack/config.lua b/resources/[inventory]/nord_backpack/config.lua new file mode 100644 index 000000000..264dca156 --- /dev/null +++ b/resources/[inventory]/nord_backpack/config.lua @@ -0,0 +1,57 @@ +Config = {} + +-- Bag component IDs and their inventory properties +-- These are the drawable IDs for the "bags" component (component ID 5) +Config.Backpacks = { + -- [drawableId] = inventory properties + [31] = { -- Example: Small backpack drawable ID + maxweight = 10000, -- 10kg + slots = 10, + label = 'Small Backpack' + }, + [41] = { -- Example: Medium backpack drawable ID + maxweight = 20000, -- 20kg + slots = 15, + label = 'Medium Backpack' + }, + [44] = { -- Example: Large backpack drawable ID + maxweight = 30000, -- 30kg + slots = 20, + label = 'Large Backpack' + }, + [52] = { -- Example: Tactical backpack drawable ID + maxweight = 40000, -- 40kg + slots = 25, + label = 'Tactical Backpack' + }, + [81] = { -- Example: Hiking backpack drawable ID + maxweight = 50000, -- 50kg + slots = 30, + label = 'Hiking Backpack' + } +} + +-- Key to open backpack inventory (default: B) +Config.BackpackKey = 'B' + +-- Notification settings +Config.Notifications = { + noBackpack = { + title = 'Backpack', + description = 'You don\'t have a backpack equipped!', + type = 'error' + }, + backpackOpened = { + title = 'Backpack', + description = 'You opened your backpack', + type = 'success' + } +} + +-- Logging settings +Config.Logs = { + enabled = true, + webhookName = 'backpacks', -- Name of the webhook in qb-log + openTitle = 'Backpack Opened', + openColor = 'blue' +} diff --git a/resources/[inventory]/nord_backpack/fxmanifest.lua b/resources/[inventory]/nord_backpack/fxmanifest.lua new file mode 100644 index 000000000..99bc38c89 --- /dev/null +++ b/resources/[inventory]/nord_backpack/fxmanifest.lua @@ -0,0 +1,26 @@ +fx_version 'cerulean' +game 'gta5' +lua54 'yes' + +author 'YourName' +description 'Backpack System - Extra inventory for equipped clothing bags' +version '1.0.0' + +shared_scripts { + 'config.lua', + '@ox_lib/init.lua' +} + +client_scripts { + 'client.lua' +} + +server_scripts { + 'server.lua' +} + +dependencies { + 'qb-core', + 'ox_lib', + 'tgiann-inventory' +} diff --git a/resources/[inventory]/nord_backpack/server.lua b/resources/[inventory]/nord_backpack/server.lua new file mode 100644 index 000000000..64104adc8 --- /dev/null +++ b/resources/[inventory]/nord_backpack/server.lua @@ -0,0 +1,65 @@ +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) diff --git a/resources/[inventory]/tgiann-inventory/items/items.lua b/resources/[inventory]/tgiann-inventory/items/items.lua index e19a317bb..467be941c 100644 --- a/resources/[inventory]/tgiann-inventory/items/items.lua +++ b/resources/[inventory]/tgiann-inventory/items/items.lua @@ -2931,7 +2931,7 @@ itemsData = { type = 'item', unique = false, description = 'Freude für deinen Vierbeiner.', - image = 'tier_leckerlies.png', + image = 'tier_leckerlis.png', shouldClose = true, label = 'Tier Leckerlis', name = 'tier_leckerlis',