1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-07-30 01:18:19 +02:00
parent 03da67c996
commit 135f0e163e
5 changed files with 225 additions and 1 deletions

View file

@ -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)

View file

@ -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'
}

View file

@ -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'
}

View file

@ -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)

View file

@ -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',