forked from Simnation/Main
ed
This commit is contained in:
parent
53a32aaa63
commit
747cfdf9a1
2 changed files with 34 additions and 12 deletions
|
@ -107,22 +107,43 @@ 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
|
||||
|
||||
-- Use the clean weapon metadata instead of the original
|
||||
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 properly formatted weapon metadata
|
||||
exports["tgiann-inventory"]:AddItem(source, item, amount, nil, weaponMetadata, nil)
|
||||
else
|
||||
-- For non-weapon items, use the original metadata
|
||||
|
@ -130,6 +151,7 @@ elseif GetResourceState('tgiann-inventory') == 'started' then
|
|||
end
|
||||
|
||||
|
||||
|
||||
elseif GetResourceState('origen_inventory') == 'started' then
|
||||
exports['origen_inventory']:addItem(source, item, amount, metadata, false)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue