forked from Simnation/Main
Update sv_function.lua
This commit is contained in:
parent
aa02123992
commit
e283a1c311
1 changed files with 18 additions and 16 deletions
|
@ -103,27 +103,29 @@ function AddItem(source, item, amount, metadata)
|
|||
exports['qs-inventory']:AddItem(source, item, amount, false, metadata)
|
||||
|
||||
elseif GetResourceState('tgiann-inventory') == 'started' then
|
||||
-- Convert item name to uppercase for consistent comparison
|
||||
local upperItem = string.upper(item)
|
||||
-- For tgiann-inventory, we need to handle weapons differently
|
||||
local upperItem = string.upper(tostring(item))
|
||||
|
||||
-- Handle weapons specifically
|
||||
if string.match(upperItem, "WEAPON_") then
|
||||
-- Always generate a new string serie for weapons
|
||||
metadata.serie = tostring(math.random(100000, 999999))
|
||||
-- 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
|
||||
}
|
||||
|
||||
-- Set default weapon metadata if not provided
|
||||
metadata.ammo = metadata.ammo or 0
|
||||
metadata.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))
|
||||
|
||||
-- Special handling for carbine rifle
|
||||
if upperItem == "WEAPON_CARBINERIFLE" then
|
||||
-- Additional specific settings for carbine rifle if needed
|
||||
-- This ensures the carbine rifle always has valid metadata
|
||||
end
|
||||
end
|
||||
|
||||
-- Call the tgiann-inventory export with properly formatted metadata
|
||||
-- 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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue