You don't need to change functions like AddItem, RemoveItem, GetItemByName or etc in your other scripts, you can use qb's and esx's functions
GetItemList
Copy exports[ "tgiann-inventory" ]:GetItemList()
Return :
Example
Copy local allItems = exports[ "tgiann-inventory" ]:GetItemList()
GetItemLabel
Copy exports[ "tgiann-inventory" ]:GetItemLabel(item)
Return :
Parameters :
Example
Copy local label = exports[ "tgiann-inventory" ]:GetItemLabel( "bandage" )
GetPlayerItems
Copy exports[ "tgiann-inventory" ]:GetPlayerItems(src)
Return :
Parameters :
Example
Copy local src = source
local playerItems = exports[ "tgiann-inventory" ]:GetPlayerItems(src)
GetPlayerClotheItems
Copy exports[ "tgiann-inventory" ]:GetPlayerClotheItems(src)
Return :
Parameters :
Example
Copy local src = source
local playerClotheItems = exports[ "tgiann-inventory" ]:GetPlayerClotheItems(src)
GetTotalWeight
Copy exports[ "tgiann-inventory" ]:GetTotalWeight(items)
Return :
Parameters :
Example
Copy local items = {
[ "1" ] = { item = "bandage" , amount = 5 },
[ "4" ] = { item = "arrow" , amount = 2 },
}
local weight = exports[ "tgiann-inventory" ]:GetTotalWeight(items)
return weight < 10
AddItem
Copy exports[ "tgiann-inventory" ]:AddItem(source, item, amount, slot, metadata, isClotheSlot)
Return :
Parameters :
Example
Copy local src = source
local metadata = {
level = 2
}
local success = exports[ "tgiann-inventory" ]:AddItem(src, "bandage" , 2 , nil , metadata, false )
if success then
print ( "item added" )
end
RemoveItem
Copy exports[ "tgiann-inventory" ]:RemoveItem(source, item, amount, keyName, metadata)
Return :
Parameters :
Example
Copy local src = source
local itemData = exports[ "tgiann-inventory" ]:GetItemByName(src, "bandage" )
if itemData.amount > 0 then
local success = exports[ "tgiann-inventory" ]:RemoveItem(src, "bandage" , 1 , itemData.key)
if success then
print ( "item added" )
end
end
CanCarryItem
Copy exports[ "tgiann-inventory" ]:CanCarryItem(source, item, amount)
Return :
Parameters :
Example
Copy local src = source
local canCarry = exports[ "tgiann-inventory" ]:CanCarryItem(src, "bandage" , 100 )
if canCarry then
exports[ "tgiann-inventory" ]:AddItem(src, "bandage" , 100 )
end
CanCarryItems
Copy exports[ "tgiann-inventory" ]:CanCarryItems(source, items)
Return :
Parameters :
Example
Copy local src = source
local items = {
{name = "bandage" , amount = "3" },
{name = "gold" , amount = "1" },
}
local canCarry = exports[ "tgiann-inventory" ]:CanCarryItems(src, items)
if canCarry then
for i = 1 , # items do
exports[ "tgiann-inventory" ]:AddItem(src, items[i].name, items[i].amount)
end
end
ClearInventory
Copy exports[ "tgiann-inventory" ]:ClearInventory(source)
Return : None
Parameters :
GetItemByName
Copy exports[ "tgiann-inventory" ]:GetItemByName(source, item, metadata)
Return :
Parameters :
Example
Copy local src = source
local itemData = exports[ "tgiann-inventory" ]:GetItemByName(src, "bandage" )
if itemData.amount > 0 then
exports[ "tgiann-inventory" ]:RemoveItem(src, "bandage" , itemData.amount)
end
GetItemBySlot
Copy exports[ "tgiann-inventory" ]:GetItemBySlot(source, slot, metadata)
Return :
Parameters :
Example
Copy local src = source
local keyName = "tgi_001_bandage"
local itemData = exports[ "tgiann-inventory" ]:GetItemBySlot(src, slot)
if itemData.amount > 0 then
exports[ "tgiann-inventory" ]:RemoveItem(src, itemData.name, itemData.amount)
end
HasItem
Copy exports[ "tgiann-inventory" ]:HasItem(src, items, amount)
Return :
Parameters :
Example
Copy local src = source
local has1 = exports[ "tgiann-inventory" ]:HasItem(src, "bandage" , 2 )
local has2 = exports[ "tgiann-inventory" ]:HasItem(src, { "bandage" , "armor" }, 2 )
RepairWeapon
Copy exports[ "tgiann-inventory" ]:RepairWeapon(src, slot, value)
Return :
Parameters :
Example
Copy local src = source
local playerItems = exports[ "tgiann-inventory" ]:GetPlayerItems(src)
for slot, itemData in pairs (playerItems) do
if item.name == "weapon_pistol" then
exports[ "tgiann-inventory" ]:RepairWeapon(src, slot, 100 )
end
end
CreateCustomStashWithItem
Custom creates stash inventory
Copy exports[ "tgiann-inventory" ]:CreateCustomStashWithItem(stashUniqId, items)
Return :
Parameters :
Example
Copy --Server
local items = {
{
name = "bandage"
amount = 2 ,
},
{
name = "waeapon_pistol"
amount = 2 ,
info = {
ammo = 500
}
},
}
exports[ "tgiann-inventory" ]:CreateCustomStashWithItem( "airdrop_1" , items)
--Client
TriggerServerEvent( "tgiann-inventory:server:OpenInventory" , "stash" , "airdrop_1" )
GetItemByNameFromSecondInventory
Returns the data of the item in the stash
Copy exports[ "tgiann-inventory" ]:GetItemByNameFromSecondInventory(invType, invName, item)
Return :
Parameters :
Example
Copy local src = source
local itemData = exports[ "tgiann-inventory" ]:GetItemByNameFromSecondInventory( "stash" , "airdrop_01" , "bandage" )
return itemData.amount > 0
RemoveItemFromSecondInventory
Delete items from stash
Copy exports[ "tgiann-inventory" ]:RemoveItemFromSecondInventory(invType, invName, item, amount, slot)
Return :
Parameters :
Example
Copy local src = source
local stashId = "airdrop_01"
local itemData = exports[ "tgiann-inventory" ]:GetItemByNameFromSecondInventory( "stash" , stashId, "bandage" )
if itemData.amount > 0 then
local success = exports["tgiann-inventory"]:RemoveItemFromSecondInventory("stash", stashId, "bandage", 1, itemData.slot)
if success then
print ( "item removed" )
end
end
AddItemFromSecondInventory
Add items from stash
Copy exports[ "tgiann-inventory" ]:AddItemFromSecondInventory(invType, invName, item, amount, slot)
Return :
Parameters :
Example
Copy local src = source
local stashId = "airdrop_01"
local success = exports[ "tgiann-inventory" ]:AddItemFromSecondInventory( "stash" , stashId, "bandage" , 1 )
if success then
print ( "item added" )
end
UpdateItemMetadata
Updates the item's info data
Copy exports[ "tgiann-inventory" ]:UpdateItemMetadata(src, item, slot, metadata)
Return : None
Parameters :
Example
Copy local src = source
local itemData = exports[ "tgiann-inventory" ]:GetItemByName(src, "weapon_pistol" )
local newMetadata = {
ammo = 200
}
exports[ "tgiann-inventory" ]:UpdateItemMetadata(src, "weapon_pistol" , itemData.slot, newMetadata)
DeleteInventory
deletes all data of the inventory
Copy exports[ "tgiann-inventory" ]:DeleteInventory(invType, invId)
Return : None
Parameters :
Example
Copy exports[ "tgiann-inventory" ]:DeleteInventory( "stash" , "airdrop_01" )
exports[ "tgiann-inventory" ]:DeleteInventory( "glovebox" , "TL001TL" )
GiveClotheItem
Copy exports[ "tgiann-inventory" ]:GiveClotheItem(src, model, itemName, data, isClotheSlot)
Return : None
Parameters :
Example
Copy local src = source
local model = joaat( "mp_f_freemode_01" )
--[[
0: Helmet - Hat (c_helmet) (Prop)
1: Mask (c_mask)
1: Glasses (c_glasses) (Prop)
2: Ear (c_ear) (Prop)
4: Pants (c_pants)
5: Bag (c_bag)
6: Shoes (c_shoes)
6: Watch (c_watch) (Prop)
7: Chain (c_necklace)
7: Bracelets (c_bracelet) (Prop)
9: Kevlar (c_bproof)
10: Decals (c_decal)
3: Arms (c_torso)
8: Tshirt (c_torso)
11: Torso (c_torso)
]]--
exports[ "tgiann-inventory" ]:GiveClotheItem(src, model, "c_shoes" , {
[ "6" ] = { --shoes
Prop = 26 ,
Texture = 0
}
}, false )
exports[ "tgiann-inventory" ]:GiveClotheItem(src, model, "c_torso" , {
[ "3" ] = { --arms
Prop = 3 ,
Texture = 0
},
[ "8" ] = { --Tshirt
Prop = 14 ,
Texture = 0
},
[ "11" ] = { --Torso
Prop = 60 ,
Texture = 0
}
}, false )
exports[ "tgiann-inventory" ]:GiveClotheItem(src, model, "c_pants" , {
[ "4" ] = { --pants
Prop = 39 ,
Texture = 0
},
}, false )
RegisterShop
Copy exports[ "tgiann-inventory" ]:RegisterShop(shopName, items)
Return : None
Parameters :
Example
Copy local items = {
{ name = 'beer' , price = 7 , amount = 50 , type = 'item' },
{ name = 'whiskey' , price = 10 , amount = 50 , type = 'item' },
{ name = 'vodka' , price = 12 , amount = 50 , type = 'item' },
}
exports[ "tgiann-inventory" ]:RegisterShop( "policeshop2" , items)
RegisterCraft
Copy exports[ "tgiann-inventory" ]:RegisterCraft(category, label, items)
Return : None
Parameters :
Example
Copy local items = {
{ name = 'beer' , price = 7 , amount = 50 , type = 'item' },
{ name = 'whiskey' , price = 10 , amount = 50 , type = 'item' },
{ name = 'vodka' , price = 12 , amount = 50 , type = 'item' },
}
exports[ "tgiann-inventory" ]:RegisterCraft( "policecraft" , "Fake Police Crafting" , items)
RegisterJobCraft
Copy exports[ "tgiann-inventory" ]:RegisterJobCraft(jobName, label, items)
Return : None
Parameters :
Example
Copy local items = {
{ name = 'beer' , price = 7 , amount = 50 , type = 'item' },
{ name = 'whiskey' , price = 10 , amount = 50 , type = 'item' },
{ name = 'vodka' , price = 12 , amount = 50 , type = 'item' },
}
exports[ "tgiann-inventory" ]:RegisterJobCraft( "police" , "Fake Police Crafting" , items)