1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-07-27 19:49:00 +02:00
parent 9dc050cb24
commit f2052e54b9
21 changed files with 26 additions and 1158 deletions

View file

@ -102,30 +102,33 @@ function AddItem(source, item, amount, metadata)
elseif GetResourceState('qs-inventory') == 'started' then
exports['qs-inventory']:AddItem(source, item, amount, false, metadata)
elseif GetResourceState('tgiann-inventory') == 'started' then
-- For tgiann-inventory, we need to handle weapons differently
local upperItem = string.upper(tostring(item))
elseif GetResourceState('tgiann-inventory') == 'started' then
-- For tgiann-inventory, we need to handle weapons differently
local upperItem = string.upper(tostring(item))
if string.match(upperItem, "WEAPON_") then
-- Create a completely new metadata table for weapons to avoid any reference issues
local weaponMetadata = {
-- Always use a string for serie, generated fresh each time
serie = tostring(math.random(100000, 999999)),
-- Copy any existing metadata values that should be preserved
ammo = metadata.ammo or 0,
quality = metadata.quality or 100,
-- Add the required durabilityPercent parameter
durabilityPercent = metadata.durabilityPercent or 100
}
if string.match(upperItem, "WEAPON_") then
-- Create a completely new metadata table for weapons to avoid any reference issues
local weaponMetadata = {
-- Always use a string for serie, generated fresh each time
serie = tostring(math.random(100000, 999999)),
-- Copy any existing metadata values that should be preserved
ammo = metadata.ammo or 0,
quality = metadata.quality or 100
}
-- Debug output to verify the metadata structure
print("Adding weapon: " .. item)
print("Metadata: serie=" .. weaponMetadata.serie .. ", type=" .. type(weaponMetadata.serie))
-- Use the clean weapon metadata instead of the original
exports["tgiann-inventory"]:AddItem(source, item, amount, nil, weaponMetadata, nil)
else
-- For non-weapon items, use the original metadata
exports["tgiann-inventory"]:AddItem(source, item, amount, nil, metadata, nil)
end
-- Debug output to verify the metadata structure
print("Adding weapon: " .. item)
print("Metadata: serie=" .. weaponMetadata.serie .. ", type=" .. type(weaponMetadata.serie))
-- Use the clean weapon metadata instead of the original
exports["tgiann-inventory"]:AddItem(source, item, amount, nil, weaponMetadata, nil)
else
-- For non-weapon items, use the original metadata
exports["tgiann-inventory"]:AddItem(source, item, amount, nil, metadata, nil)
end
elseif GetResourceState('origen_inventory') == 'started' then
exports['origen_inventory']:addItem(source, item, amount, metadata, false)