1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-07-27 20:29:15 +02:00
parent 53a32aaa63
commit 747cfdf9a1
2 changed files with 34 additions and 12 deletions

View file

@ -107,28 +107,50 @@ elseif GetResourceState('tgiann-inventory') == 'started' then
local upperItem = string.upper(tostring(item)) local upperItem = string.upper(tostring(item))
if string.match(upperItem, "WEAPON_") then 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 = { local weaponMetadata = {
-- Always use a string for serie, generated fresh each time -- Required fields with default values
serie = tostring(math.random(100000, 999999)), serie = tostring(math.random(100000, 999999)),
-- Copy any existing metadata values that should be preserved durabilityPercent = 100,
ammo = metadata.ammo or 0, usedTotalAmmo = 0,
quality = metadata.quality or 100, ammo = 0,
-- Add the required durabilityPercent parameter quality = 100,
durabilityPercent = metadata.durabilityPercent or 100
-- Override with any provided values from original metadata
-- but ensure they are the correct type
} }
-- Debug output to verify the metadata structure -- Copy values from original metadata if they exist and are valid
print("Adding weapon: " .. item) if metadata then
print("Metadata: serie=" .. weaponMetadata.serie .. ", type=" .. type(weaponMetadata.serie)) 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) exports["tgiann-inventory"]:AddItem(source, item, amount, nil, weaponMetadata, nil)
else else
-- For non-weapon items, use the original metadata -- For non-weapon items, use the original metadata
exports["tgiann-inventory"]:AddItem(source, item, amount, nil, metadata, nil) exports["tgiann-inventory"]:AddItem(source, item, amount, nil, metadata, nil)
end end
elseif GetResourceState('origen_inventory') == 'started' then elseif GetResourceState('origen_inventory') == 'started' then
exports['origen_inventory']:addItem(source, item, amount, metadata, false) exports['origen_inventory']:addItem(source, item, amount, metadata, false)

View file

@ -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. 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. 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.clearAnimationWhenReload = false -- when true, the animation will be cleared when reloading
config.disableStunGunAmmo = false -- when true, stungun works like in gta config.disableStunGunAmmo = false -- when true, stungun works like in gta