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)
|
exports['qs-inventory']:AddItem(source, item, amount, false, metadata)
|
||||||
|
|
||||||
elseif GetResourceState('tgiann-inventory') == 'started' then
|
elseif GetResourceState('tgiann-inventory') == 'started' then
|
||||||
-- Convert item name to uppercase for consistent comparison
|
-- For tgiann-inventory, we need to handle weapons differently
|
||||||
local upperItem = string.upper(item)
|
local upperItem = string.upper(tostring(item))
|
||||||
|
|
||||||
-- Handle weapons specifically
|
|
||||||
if string.match(upperItem, "WEAPON_") then
|
if string.match(upperItem, "WEAPON_") then
|
||||||
-- Always generate a new string serie for weapons
|
-- Create a completely new metadata table for weapons to avoid any reference issues
|
||||||
metadata.serie = tostring(math.random(100000, 999999))
|
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
|
-- Debug output to verify the metadata structure
|
||||||
metadata.ammo = metadata.ammo or 0
|
print("Adding weapon: " .. item)
|
||||||
metadata.quality = metadata.quality or 100
|
print("Metadata: serie=" .. weaponMetadata.serie .. ", type=" .. type(weaponMetadata.serie))
|
||||||
|
|
||||||
-- Special handling for carbine rifle
|
-- Use the clean weapon metadata instead of the original
|
||||||
if upperItem == "WEAPON_CARBINERIFLE" then
|
exports["tgiann-inventory"]:AddItem(source, item, amount, nil, weaponMetadata, nil)
|
||||||
-- Additional specific settings for carbine rifle if needed
|
else
|
||||||
-- This ensures the carbine rifle always has valid metadata
|
-- For non-weapon items, use the original metadata
|
||||||
end
|
exports["tgiann-inventory"]:AddItem(source, item, amount, nil, metadata, nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Call the tgiann-inventory export with properly formatted metadata
|
|
||||||
exports["tgiann-inventory"]:AddItem(source, item, amount, nil, metadata, nil)
|
|
||||||
|
|
||||||
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)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue