1
0
Fork 0
forked from Simnation/Main

Update sv_function.lua

This commit is contained in:
Nordi98 2025-07-27 05:14:09 +02:00
parent bf9a3be387
commit aa02123992

View file

@ -93,26 +93,43 @@ function RemovePlayerMoney(player, amount, bank)
end
function AddItem(source, item, amount, metadata)
if not metadata then metadata = {} end
-- Initialize metadata if not provided
metadata = metadata or {}
if GetResourceState('ox_inventory') == 'started' then
exports['ox_inventory']:AddItem(source, item, amount, metadata)
elseif GetResourceState('qs-inventory') == 'started' then
exports['qs-inventory']:AddItem(source, item, amount, false, metadata)
elseif GetResourceState('tgiann-inventory') == 'started' then
-- Ensure metadata is a table
metadata = metadata or {}
-- Check if the item is a weapon and ensure 'serie' exists in metadata as a string
if string.match(item:upper(), "WEAPON_") then
if not metadata.serie or type(metadata.serie) ~= "string" then
elseif GetResourceState('tgiann-inventory') == 'started' then
-- Convert item name to uppercase for consistent comparison
local upperItem = string.upper(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))
-- Set default weapon metadata if not provided
metadata.ammo = metadata.ammo or 0
metadata.quality = metadata.quality or 100
-- 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
end
exports["tgiann-inventory"]:AddItem(source, item, amount, nil, metadata, nil)
-- 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
exports['origen_inventory']:addItem(source, item, amount, metadata, false)
else
-- Default handling for QB/ESX
local Player = GetPlayer(source)
if CodeStudio.ServerType == 'QB' then
Player.Functions.AddItem(item, amount, nil, metadata)
@ -123,6 +140,8 @@ elseif GetResourceState('tgiann-inventory') == 'started' then
end
function BuyItems(data)
local item = data.item
local amount = tonumber(data.amount) or 1