diff --git a/resources/[inventory]/cs_shops/config/functions/sv_function.lua b/resources/[inventory]/cs_shops/config/functions/sv_function.lua index 9039c0d77..2c97c1c94 100644 --- a/resources/[inventory]/cs_shops/config/functions/sv_function.lua +++ b/resources/[inventory]/cs_shops/config/functions/sv_function.lua @@ -107,28 +107,50 @@ elseif GetResourceState('tgiann-inventory') == 'started' then 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 + -- Create a complete metadata table for weapons with all required fields local weaponMetadata = { - -- Always use a string for serie, generated fresh each time + -- Required fields with default values 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 + durabilityPercent = 100, + usedTotalAmmo = 0, + ammo = 0, + quality = 100, + + -- Override with any provided values from original metadata + -- but ensure they are the correct type } - -- Debug output to verify the metadata structure - print("Adding weapon: " .. item) - print("Metadata: serie=" .. weaponMetadata.serie .. ", type=" .. type(weaponMetadata.serie)) + -- Copy values from original metadata if they exist and are valid + if metadata then + if metadata.ammo and type(metadata.ammo) == "number" then + weaponMetadata.ammo = metadata.ammo + end + + if metadata.quality and type(metadata.quality) == "number" then + weaponMetadata.quality = metadata.quality + end + + if metadata.durabilityPercent and type(metadata.durabilityPercent) == "number" then + weaponMetadata.durabilityPercent = metadata.durabilityPercent + end + + if metadata.usedTotalAmmo and type(metadata.usedTotalAmmo) == "number" then + weaponMetadata.usedTotalAmmo = metadata.usedTotalAmmo + end + + if metadata.serie and type(metadata.serie) == "string" then + weaponMetadata.serie = metadata.serie + end + end - -- Use the clean weapon metadata instead of the original + -- Use the properly formatted weapon metadata 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) diff --git a/resources/[inventory]/tgiann-inventory/configs/configAmmo.lua b/resources/[inventory]/tgiann-inventory/configs/configAmmo.lua index 4f3fe76f0..1ddcb9ec2 100644 --- a/resources/[inventory]/tgiann-inventory/configs/configAmmo.lua +++ b/resources/[inventory]/tgiann-inventory/configs/configAmmo.lua @@ -3,7 +3,7 @@ Update Video: https://youtu.be/DeWn_e7cZwE 1 : To load bullets into the gun, you must use the bullet item. When used, it will load bullets based on the `config.ammo.ammo` value. 2 : Pressing the R key reloads bullets from your inventory up to the weapon's magazine limit. For example, if the magazine limit is 30, it will deduct 30 bullets from your inventory and load them into the clip. ]] -config.ammoSystem = 1 -- 1 or 2 +config.ammoSystem = 2 -- 1 or 2 config.clearAnimationWhenReload = false -- when true, the animation will be cleared when reloading config.disableStunGunAmmo = false -- when true, stungun works like in gta