Introduction


Welcome to the Avalanche Productions Inventory documentation.
We highly recommended you read the entire documentation from start to finish.
The documentation covers the resources assembly, installation, maintenance and use.

Our inventory system can be functional within 5 minutes.
This resource is in-depth and able to be deployed with any server setup.
Full configuration is not required.

We pride ourselves in providing full support.

Requirements


To experience our resource to it's greatest potential there will be a few things you need to become familiar with.
The guide contains everything you will need to know.

Identifier

The inventory resource is standalone - it has no requirements such as ESX or vRP.
The resource only requires a unique identifier for the player inventories.
This is handled by the export GetCharId found in the client lua file.
If not using ESX, you can use Steam ID, Multichar ID, etc.
Though not required, by default the inventory uses the ESX identifier.

Items

To spawn items they must be defined.
All clothing has been pre-defined, up to the FiveM build 2060.
Also included are a few examples such as bags, weapons, and weapon attachments.
If using ESX, by default the items are placed directly into the player's clothing.
Clothes are required to contain these items, unless using a grid-based player inventory.

Clothing

Adding clothing to the player is very simple. There are two store resources included.
If you would like more freedom, you are able to modify your current code using this example.

Installation - Inventory


Place the inventory folder into your server resources directory.
Add ensure inventory to the servers configuration (default server.cfg) to make it run on startup.
Place your Tebex Purchase ID or key into the key.txt

All of the client sided external functions that the inventory uses are handled by the client.lua - located in the client folder.
These include the logic used for generating vehicle inventories, as well as identifying the player.
There is more information provided about these below in the Logic section.

By default the inventory is configured for use with ESX.

Installation - Store


The inventory includes two options to use for a clothing store.
We recommend disabling your previous clothing stores when using these.
If you do not want to use clothing you can skip this step.

Store (Beta)
We recommend using the store-beta resource included with the inventory.
This store contains all of the clothes up to game build 2060 - compatibility options will be provided in the future.
It is pre-configured and randomly generates clothing at different price points based on the configuration file.
These stores are preconfigured with all of the vanilla coordinates.
Press E at any $ marker to access it.

Known limitations (store-beta):
  • It cannot be used for anything other than clothes.
  • The store currently does not charge money.
  • There are no blips included.
  • No icons for glasses.
  • No bags in stores.

Legacy Store
This was orginally provided as an example.
It will require configuration and does not have any previews of the clothing.
The legacy store store is only recommended to sell items besides clothing, such as weapons, items, etc.
The demonstration clothing store is located at the coordinates 71.27, -1400.45, 29.37

If you would not like to use either of these and would still like to use clothing, please check out the Clothing Automation example.

Installation - ESX


Included is a readmeesx.txt
This is a conversion kit provided to use ESX scripts with the inventory without having to modify the scripts themselves.

If you not using the clothing-based slot inventories, the function prefixes must be changed from SlotInventory to Inventory
Please reference the Server Events section below.
The UseClothingInventories option is located in the config.json

To transfer the items from the database, run the command LoadESXItems in the server console.
This process is automatic. You will only need to add the icons into html/img/

If you come across any issues with this step, we provide full support via Discord

Configuration


There are multiple configuration files included and they all work together.

This section is to help you understand the structure of the objects used in the resource.
For simplified examples refer to the examples section.
The configuration files are json-based and may be configured using an online-editor such as this one.
Load the JSON, press the right-facing arrow to transform it into a table-based structure and then edit the table.
When finished press the left-facing arrow to transform the table to JSON.

If you do not understand the data-types listed, you can learn them using this Microsoft reference.

Definitions

This section describes the structure of the definition configuration.

Included are a predefined definitions located in the definition folder.
Definitions are categorized into separate files.
To add/remove definition files, edit the definitionfiles.json to match the file names in this folder.

Name (string)
As seen in the highlighted text, the definition and item name need to match.
This is used to identify the item.
It cannot contain spaces.
"item":{
  "ExteriorDimensions":{"Height":1,"Width":1},
  "Name":"item",
  "FriendlyName":"Item",
  "Icon":"img/item.png",
  "InitialWeight":1
},

FriendlyName (string)
This name is what is shown to the player to describe an item.
It is used for the item description and the items interior inventory if applicable.
"superlonganduglyitemname12345":{
  "ExteriorDimensions":{"Height":1,"Width":1},
  "Name":"superlonganduglyitemname12345",
  "FriendlyName":"Friendly Item Name",
  "Icon":"img/item.png",
  "InitialWeight":1
},

Icon (string)
A URL for the icon. Can be local or web-based.
Weapon (bool)
If true, the prop attached to the item is not equipped
Stackable (bool)
If true, the item can be stacked.
RemoveOnUse (bool)
If true, the item is removed when used. It is recommended to use this instead of external code.
MaxStack (int)
If the item is stackable, this number defines the maximum amount which can be stacked.
SlotInventoryDefinition (string)
When the item is opened (double click or right click -> open) it will open the interior inventory.
This needs to match the name of the slot inventory type you would like to open. IE: Pistol.
This is incompatible with stackable items, or items that have a grid-based interior inventory.
There is more information on this in the Slot Inventories configuration tab.
ItemTypes (string[])
These are used as categories for the items and are used for a lot of the logical features.
A few examples of this is the item generation, whitelists, blacklists, etc.
This is expandable and you can have as many as you'd like.
In the future these will allow item types to be searched.
Below is an example for a very well described nutrition bar.

"ItemTypes":["chocolate", "protein", "food", "bar", "nutritional", "peanuts"]
FillType (string)
Allows the item to be filled with items. IE: bullets -> clip.
The FillType has to match the one of the types that the item has.
The definition must have Stackable set to true.
An example is provided below with bullet and clip items.

"clip":{
  "ExteriorDimensions":{"Height":1,"Width":1},
  "Name":"clip",
  "FriendlyName":"Clip",
  "Icon":"img/clip.png",
  "Stackable":true,
  "FillType":"ammo",
  "InitialWeight":350
},
"bullets":{
  "ExteriorDimensions":{"Height":1,"Width":1},
  "MaxStack":30,
  "Name":"bullets",
  "FriendlyName":"Bullets",
  "Icon":"img/bullets.png",
  "Weapon":false,
  "Stackable":true,
  "ItemTypes":["ammo"],
  "InitialWeight":10
},
Dimensions
Used for both interior/exterior. Descriptions are provided below.
  • Height (int)
  • Width (int)
  • Weight (float)
    • Interior weight capacity.
  • WhitelistedTypes (string[])
    • If not null, blocks all item types from entering besides the ones listed.
  • BlacklistedTypes (string[])
    • Blocks the types listed from entering the inventory.
InteriorDimensions
Used for the interior of the item. Not required. Incompatible with stackable items and items with a slot inventory.
ExteriorDimensions
Required. Only uses height and width. To set the weight use the DefaultWeight property.

Provided below are examples on how you can use the white/blacklisting feature. This example would be applicable to a wallet interior as it only accepts cash and card.
"InteriorDimensions": {
  "Height": 1,
  "Width": 1,
  "Weight": 1000,
  "WhitelistedTypes":[
    "cash",
    "card"
  ],
},
This example would be applicable to a bag as it won't allow the user to place bags inside each other.
"InteriorDimensions": {
  "Height": 3,
  "Width": 4,
  "Weight": 1000,
  "BlacklistedTypes":[
    "bag"
  ],
},
Events
There are two types of events the items can have tied to them. Equip and use.

The de/equip events are fired when the item is placed/taken into the users hand slot.
An example can be seen in the predefined weapon definitions provided by default.
"Events":{
  "equip-server":"Inventory:RefreshWeapon",
  "deequip-client":"Inventory:RemoveWeapon"
},
The only thing this does is access the definitions extra data to check which weapon is to be given, and forwarded to the client.

The other type of event is a use event.
"Events":{
  "use-server":"Metabolism:EatFood",
  "use-client":"Emotes:EatFood"
},
Below is a structure of the data that these events send.
  • Client
    • Unique ID
  • Server
    • Source Handle
    • Unique ID
    • Containing Inventory ID
    • Containing Slot (if applicable)

Inventory Sizes


  • Height (int)
  • Width (int)
  • Weight (float)
    • Interior weight capacity.
  • WhitelistedTypes (string[])
    • If not null, blocks all item types from entering besides the ones listed.
  • BlacklistedTypes (string[])
    • Blocks the types listed from entering the inventory.

When opening an inventory and declaring a type, it will try and grab from this list of sizes if available.

Item Generation


Dimensions (Inventory Size Object)
Same structure as the inventory sizes listed in the tab above.
If using whitelist/blacklist the item generation will ignore this and the clients will have restrictions.
Types (string[])
These types are related to the 'Groups' in the Item Rarity configuration.
It will collect all items that contain the group and include them in the random generation.
AcceptableAmounts (int[])
This is a pool to determine how many items are generated.

Use this in correlation with the Item Rarity feature.
To open an inventory with generation, use the AccessSpecial event.

Item Rarity


ItemId (string)
The ID of item to spawn.
Weight (int)
The rarity system included is weight based. It takes the sum of all of the weights before generation.
If there are 100 items listed with a weight of 5, the total will be 500.
If you add another item that has a weight of 100, your chance to get the new item is 100/600.
Gradient (int[])
This is a gradient to determine what amount of the provided item is generated.
The system picks two of the numbers included and finds a number between them.
Groups (string[])
This is used for the item generation.

Slot Inventories


By default the player uses a slot-based inventory.
This allows for equipping items such as bags, weapons, and clothing very simple
  • BackgroundImage (string)
    • Experimental feature to add a background image to the slot inventory (must be windowed)
  • Windowed (bool)
    • If false the inventory cannot be moved.
  • Title (string)
    • Display text for inventory window.
  • Left (int)
    • Spawn location offset (pixels)
  • Top (int)
    • Spawn location offset (pixels)
  • Width (int)
    • Window width (pixels)
  • Height (int)
    • Window height (pixels)
  • Slots (dictionary)
    • Id (string)
      • Used to identify the slot.
    • Title (string)
      • Text placed directly in the slot.
    • Left (int)
      • Relative to window (pixels)
    • Top (int)
      • Relative to window (pixels)
    • Width (int)
      • Width of slot cell (pixels)
    • Height (int)
      • Height of slot cell (pixels)
    • Accepts (string[])
      • A list of the items that the slot accepts.
        Reference the types listed in the item definitions.
    • Icon (string)
      • URL for slot background icon. Experimental.

One of the examples that have been included is a pistol, allowing you to equip attachments via slots.
"Pistol": {
    "BackgroundImage": "img/pistol.png",
    "Windowed": true,
    "Title": "Pistol",
    "Left": 840,
    "Top": 420,
    "Width": 245,
    "Height": 75,
    "Slots": {
      "pistol-silencer": {
        "Id": "pistol-silencer",
        "Title": "Silencer",
        "Left": 5,
        "Top": 5,
        "Width": 75,
        "Height": 75,
        "Accepts": [
          "9mm_silencer"
        ],
        "Icon": ""
      },
      "pistol-flashlight": {
        "Id": "pistol-flashlight",
        "Title": "Light",
        "Left": 85,
        "Top": 5,
        "Width": 75,
        "Height": 75,
        "Accepts": [
          "flashlight"
        ],
        "Icon": ""
      },
      "pistol-magazine": {
        "Id": "pistol-magazine",
        "Title": "Clip",
        "Left": 165,
        "Top": 5,
        "Width": 75,
        "Height": 75,
        "Accepts": [
          "9mm_clip"
        ],
        "Icon": ""
      }
    },

Logic


The Logic section is to show how existing inventory features work.

Vehicle Inventories

The vehicle inventories are handled by the lua file included in the client folder.
These are open source and created for ease of access.
There is more information on expanding these in the examples section.
OpenVehicleInsideInventory
This export is fired when the inventory is opened and the player is inside of a vehicle.
By default there are 3 inventories opened as listed below.
  • Console
    • Accessible from first four vehicle seats
  • Glovebox
    • Accessible from driver and passenger seats
  • Seat
    • Unique for each seat

OpenVehicleOutsideInventory
This export is fired when the inventory is opened and the player is facing a vehicle.
Originally used for trunk. Can be configured to do otherwise, such as open the seat inventories, engine bay, etc from outside of the car.
By default, to access the trunk the trunk must be opened physically.

Trunk Sizes
By default there is a configuration for trunk sizes located in the same file.
local trunkSizes = {
  [0] = {4,4, 50000.0},
  [7] = {3,4, 50000.0},
  [10] = {11,11, 100000.0},
  [11] = {10,10, 100000.0},
  [12] = {10,10, 100000.0},
  [20] = {14,14, 100000.0},
}
The first number in the brackets is the vehicle class.
Followed by the width, height, and size.

Removing Door Check
Some users have complained about having to use another script to open the trunk.
If you would like to disable the check to see if it's open, please remove the lines highlighted below
exports("OpenVehicleOutsideInventory", function (vehicle) --if you want you can do raycasts and check if doors are open, etc 
    local class = GetVehicleClass(vehicle)
    local trunkdoors = {5}
    if class == 10 or class == 11 or class == 12 or class == 20 then trunkdoors = {3,4} end

    for k,v in pairs(trunkdoors) do
      if (GetVehicleDoorAngleRatio(vehicle, v) > 0) then
        local id = VehicleIdentifier(vehicle)
        if trunkSizes[class] ~= nil then
          TriggerServerEvent("Inventory:AccessSize", id.."-trunk", trunkSizes[class][1], trunkSizes[class][2], trunkSizes[class][3], "Trunk")
        else
            TriggerServerEvent("Inventory:Access", id.."-trunk", "Trunk")
          end
          break
      end
  end
end)

Lockable Inventories

Included is a feature that allows items are able to be locked and not opened.
This is preconfigured and uses the item's extra data.
There are two unlock options that are able to be configured with the item definitions. These is not required.
Tutorial
The following example spawns a box that is locked. It is programmed in lua.
You can then unlock this with one of the two methods also explained below.

Client
TriggerServerEvent("Inventory:Access", "testinventory")
Wait(100)
TriggerServerEvent("Inventory:LockedBoxExample", "testinventory")

Server
RegisterServerEvent("Inventory:LockedBoxExample")
AddEventHandler("Inventory:LockedBoxExample", function(inventory)
  local boxid = exports['inventory']:InventoryAddItem("box", inventory)
  local locked = exports['inventory']:SetItemExtraData(boxid, "locked", true)
end)
Unlocking
There are two methods of unlocking the item, either via the item definition or code-based.
To unlock via code simply set the locked value to false.
local locked = exports['inventory']:SetItemExtraData(boxid, "locked", false)
To unlock via configuration, you may set the ExtraData as such in the item's definition.
In this case it would be the "box" definition.

UnlockType is what kind of item it is able to be unlocked by.
This must match the definition of the item used to unlocked, such as a key, etc

UnlockUse is if the item is removed after unlocking, this would be useful for bombs/safes, etc

"ExtraData":{
   "UnlockType":"sharp",
   "UnlockUse":false
},

Inventory Types

There are two types of inventories included.
The methods for interfacing with them are different, however usually in the same format.
You will notice further in the documentation that there are twin functions.
Such as Inventory:Access and Inventory:AccessSlotInventory
Grid-Based
Grid-Based inventories are created with a width, height, weight, and can use an optional whitelist or blacklist.
This is used for item interiors, and most other purposes.
Slot-Based
Slot-Based inventories are more complicated to setup.
They contain set slots that single items can be placed in.
By default the player uses a slot inventory.

Clothing Automation

The following is an example on how to add clothing items to the player's inventory based on the ped's visual state.
This will only work if you are using the slot inventory feature!

Client
function GiveClothingItems()
    local j1 = GetPedDrawableVariation(PlayerPedId(), 11)
    local j2 = GetPedTextureVariation(PlayerPedId(), 11)
    local l1 = GetPedDrawableVariation(PlayerPedId(), 4)
    local l2 = GetPedTextureVariation(PlayerPedId(), 4)
    local s1 = GetPedDrawableVariation(PlayerPedId(), 6)
    local s2 = GetPedTextureVariation(PlayerPedId(), 6)
    local g1 = GetPedPropIndex(PlayerPedId(), 1)
    local g2 = GetPedPropTextureIndex(PlayerPedId(), 1)
    local h1 = GetPedPropIndex(PlayerPedId(), 0)
    local h2 = GetPedPropTextureIndex(PlayerPedId(), 0)
    Wait(500)
    TriggerServerEvent("Inventory:AccessSlotInventory", "playerinventory-"..exports['inventory']:GetCharId(), "Player")
    Wait(100)
    TriggerServerEvent("Inventory:SetSlotItem", "clothing_11_"..j1.."_"..j2, "playerinventory-"..exports['inventory']:GetCharId(), "player-jacket")
    TriggerServerEvent("Inventory:SetSlotItem", "clothing_4_"..l1.."_"..l2, "playerinventory-"..exports['inventory']:GetCharId(), "player-legs")
    TriggerServerEvent("Inventory:SetSlotItem", "clothing_6_"..s1.."_"..s2, "playerinventory-"..exports['inventory']:GetCharId(), "player-feet")
    TriggerServerEvent("Inventory:SetSlotItem", "prop_1_"..g1.."_"..g2, "playerinventory-"..exports['inventory']:GetCharId(), "player-eyes")
    TriggerServerEvent("Inventory:SetSlotItem", "prop_0_"..h1.."_"..h2, "playerinventory-"..exports['inventory']:GetCharId(), "player-hat")
    TriggerServerEvent("Inventory:UpdatePlayerClothing", GetPlayerServerId(PlayerId()), "", "playerinventory-"..exports['inventory']:GetCharId())
end
What does this do?
This snippet takes the clothing configuration visible on the player (which can be changed with a menu, default clothes store, etc)
and places it into the players inventory.
Warning: it will overwrite items if they exist in the respective slots.
How do I use this?
Place the function in a client script and call when needed. It is recommended to edit an existing resource, such as character creation or clothing management.
It has also been included as an admin command /pullclothing

Handling Money

The following is an example on how to handle money.
This includes both adding/removing money, and can be used for banking/atm purposes.
The example here is more complex than the normal money system as it uses multiple types of dollar bills.
Included in the ESX conversion kit is basic money functions that use one type of bill.

Server

GetBills
The GetBills function is included to determine which bills to give based on the total.
For example GetBills(252) will return 100x2, 50x1, 1x2.
This is a helper function for this example and does not use the inventory.
Feel free to use for other purposes.
local bills = {100,50,20,10,5,1}
function GetBills(total) 
    local billsgiven = {0,0,0,0,0,0}
    for k,v in pairs(bills) do
        while total >= v do
            billsgiven[k] = billsgiven[k] + 1
            total = total - v
        end
    end
    return billsgiven
end
AddCash
The AddCash function is included to add cash. It will use the GetBills function above so make sure it is included.
The inventory argument is the ID of the inventory.
The cash argument is the dollar amount you would like to add.
The slot argument is true/false if the target inventory is slot-based.
function AddCash(inventory, cash, slot)
    slot = slot or false
    local billCounts = GetBills(cash)
    for k,v in pairs(bills) do
      if slot then
          if not exports['inventory']:InventoryAddItemStack(inventory, v.."_dollar", billCounts[k]) then
              return false
          end
      else
          if not exports['inventory']:SlotInventoryAddItemStack(inventory, v.."_dollar", billCounts[k]) then
              return false
          end
      end
    end

    return true
end
RemoveCash
The RemoveCash function is included to remove cash.
It can remove cash directly from the player, or from another inventory such as a drop-box.
This function requires both AddCash and GetBills.
If the target inventory does not have exact change the function will attempt to provide it.
The inventory argument is the ID of the inventory.
The total argument is the dollar amount you would like to remove.
The slot argument is true/false if the target inventory is slot-based.
function RemoveCash(inventory, total, slot)
    slot = slot or false
    if GetCashSum(inventory, slot) < total then return false end
    for k,v in pairs(bills) do
        local amt = 0

        if slot then
            amt = exports['inventory']:SlotInventoryItemCount(inventory, v.."_dollar")
        else
            amt = exports['inventory']:InventoryItemCount(inventory, v.."_dollar")
        end

        if (amt*v) > total then
            local remaining = 1
            local removing = true
            while removing do
                Citizen.Wait(0)
                if ((remaining+1)*v) > total then
                    removing = false
                    break
                else
                    remaining = remaining + 1
                end
            end
            if slot then
                if exports['inventory']:SlotInventoryRemoveItem(inventory, v.."_dollar", remaining) then
                    total = total - (remaining*v)
                end
            else
                if exports['inventory']:InventoryRemoveItem(inventory, v.."_dollar", remaining) then
                    total = total - (remaining*v)
                end
            end
        else
            if slot then
                if exports['inventory']:SlotInventoryRemoveItem(inventory, v.."_dollar", amt) then
                    total = total - (amt*v)
                end
            else
                if exports['inventory']:InventoryRemoveItem(inventory, v.."_dollar", amt) then
                    total = total - (amt*v)
                end
            end
        end
    end
    if total < 0 then
      AddCash(inventory, math.abs(total), slot)
    end
    return true
end
GetCashSum
The RemoveCash function is provided to get the total amount of cash in an inventory.
The inventory argument is the ID of the inventory.
The slot argument is true/false if the target inventory is slot-based.
function GetCashSum(inventory, slot)
    slot = slot or false 
    local cash = 0
    for k,v in pairs(bills) do
        local amt = 0
        if slot then
            amt = exports['inventory']:SlotInventoryItemCount(inventory, v.."_dollar")
        else
            amt = exports['inventory']:InventoryItemCount(inventory, v.."_dollar")
        end
        cash = cash + (amt*v)
    end
    return cash
end

Spawning Items

The following is an example on how to add an admin command that spawns items efficiently.
The command is able to be run by any user.
Use the following syntax: /AdminInventoryItem [item]
Try the predefined item pistol for example.
Client
RegisterCommand("AdminInventoryItem", function(s,a,c)
    TriggerServerEvent("Inventory:Access", "Admin", "Big")
    Wait(50)
    TriggerServerEvent("AdminInventoryItem", a[1])
end)
Server
RegisterNetEvent("AdminInventoryItem")
AddEventHandler("AdminInventoryItem", function(i) 
    local id = exports['inventory']:InventoryAddItem(i, "Admin") 

    print("Client: "..source.." added "..id.." to admin inventory")
end)

Searching Inventories

The following is an example on how to open and search inventories via command.
These commands are able to be run by any user.
Use the following syntax: /AdminAccess [unique id] [type]
Any string can be used for the identifier. The type is not required.
Client
RegisterCommand("AdminAccess", function(s,a,c)
    TriggerServerEvent("Inventory:Access", a[1], a[2] or "Container")
end)

RegisterCommand("AdminAccessSlot", function(s,a,c)
    TriggerServerEvent("Inventory:AccessSlotInventory", a[1], a[2] or "Container")
end)

Client Events

This section describes the events used in the client. They can be watched to use when they are fired.

Internal - These events should not be called.


Inventory:HoldItem(string item, string prop, string animation, int bone, float x, float y, float z, float rx, float ry, float rz)


Fired when an item is placed into the hands slot in the player's inventory.


Inventory:RemoveHeldItem()


Fired when an item is removed from the hands slot in the player's inventory.


Inventory:Update(string inventory)


Fired when an inventory is updated.


Inventory:SlotUpdate(string inventory)


Fired when a slot inventory is updated.


Inventory:Status(bool status)


Fired when the inventory is opened/closed.



Callable

Inventory:RequestAccess(int requester)


Opens the inventory of the player's server id (requester).


Inventory:ForceClose(string inventory)


Force closes an inventory on the client.


Inventory:Toggle(bool close)


Toggles the inventory UI when called. Set close to true if you would like to close the inventory.


Inventory:Access(string inventory, string type = "Container")


Parameters:
  • inventory: Unique identifier for the inventory
  • type: Type of inventory to open. This will also determine the size based on the inventorysizes.json

Opens specified inventory on the client who calls. This event should be called from client to server.

Example - Client

TriggerServerEvent("Inventory:Access", "testinventory", "Big")

Inventory:AccessItem(string itemId)


Parameters:
  • itemId: ID of the item wanted to use

Opens inventory of the item specified (if applicable).

Example - Client

local item = "ABCDEFG" //this needs an actual item ID
TriggerServerEvent("Inventory:AccessItem", item)

Inventory:AccessForce(int player, string inventory, string type = "Container")


Parameters:
  • player: ID of the player to open the inventory for
  • inventory: Unique identifier for the inventory
  • type: Type of inventory to open. This will also determine the size based on the inventorysizes.json

Opens inventory for the client speficied.
Should be called on server

Example - Server

local source = 1 //This needs to be a player ID
TriggerEvent("Inventory:AccessForce", source, "testinventory")

Inventory:AccessPlayer(int player)


Parameters:
  • player: ID of the player to who's inventory to open.

Opens the player inventory for the client who calls.
Should be called from client to server.

Example - Client

//this should open the nearest players inventory within 10m
local x,y,z = table.unpack(GetEntityCoords(PlayerPedId))
local ped = GetClosestPed(x,y,z,10.0,1,0,0,0,1)
local id = GetPlayerServerId(NetworkGetPlayerIndexFromPed(ped))
TriggerServerEvent("Inventory:AccessPlayer", id)

Inventory:AccessSize(string inventory, int width, int height, double weight, string type = "Container")


Parameters:
  • inventory: Unique identifier for the inventory
  • width: Width of the inventory
  • height: Height of the inventory
  • weight: Weight of the inventory
  • type: Type of inventory to open. This will also determine the size based on the inventorysizes.json

Opens the inventory for the client who calls.
Should be called from client to server.

Example - Client

TriggerServerEvent("Inventory:AccessSize", 10, 10, 100000.0, "test")

Inventory:AccessSlotInventory(string inventory, string type = "Container")


Parameters:
  • inventory: Unique identifier for the inventory
  • type: Type of inventory to open. Specified in slotinventories.json (required)

Opens the inventory for the client who calls.
Should be called from client to server.

Example - Client

TriggerServerEvent("Inventory:AccessSlotInventory", "testpistol", "pistol")

Inventory:AccessSpecial(string inventory, string type = "Container", string generation = "")


Parameters:
  • inventory: Unique identifier for the inventory
  • type: Type of inventory to open. This will also determine the size based on the inventorysizes.json
  • generation: Generation type. Specified in itemgeneration.json (required)

Opens the inventory for the client who calls and generates items.
Should be called from client to server.

Example - Client

TriggerServerEvent("Inventory:AccessSpecial", "testgeneration", "Big", "trunk")

Inventory:AccessSizeSpecial(string inventory, int width, int height, double weight, string type = "Container", string generation = "")


Parameters:
  • inventory: Unique identifier for the inventory
  • width: Width of the inventory
  • height: Height of the inventory
  • weight: Weight of the inventory
  • type: Type of inventory to open. This will also determine the size based on the inventorysizes.json
  • generation: Generation type. Specified in itemgeneration.json (required)

Opens the inventory for the client who calls and generates items.
Should be called from client to server.

Example - Client

TriggerServerEvent("Inventory:AccessSizeSpecial", "testgeneration", 10, 10, 100000.0, "ItemGenerationTest", "trunk")

Inventory:AddProximityInventory(string inventory, float x, float y, float z, float radius, string type)


Parameters:
  • inventory: Unique identifier for the inventory (recommended to create prior to using this function)
  • x: Coordinates
  • y: Coordinates
  • z: Coordinates
  • radius: Amount of distance in meters the inventory will be opened.
  • type: Display name of the inventory. This will also determine the size based on the inventorysizes.json (if the inventory is not created)

Creates a static inventory at the specified coordinates.
Should be called server side.

Example - Server

TriggerEvent("Inventory:Create", "testproximity", "Big")
TriggerEvent("Inventory:AddProximityInventory", "testproximity", 0.0, 0.0, 0.0, 10.0, "Test")

Inventory:Create(string inventory, string type)


Parameters:
  • inventory: Unique identifier for the inventory (recommended to create prior to using this function)
  • type: The size based on the inventorysizes.json

Creates an inventory for future use. This is not required for most functions.
The recommended use for this function is if you would like to place items into an inventory before opening it on the client.
Should be called server side.

Example - Server

TriggerEvent("Inventory:Create", "test", "Big")

Inventory:CreateAdvanced(string inventory, string type, int width, int height, int weight, string[] blacklist = null, string[] whitelist = null)


Parameters:
  • inventory: Unique identifier for the inventory (recommended to create prior to using this function)
  • type: Display name of inventory
  • width: Width of inventory
  • height: Height of inventory
  • weight: Weight of inventory
  • blacklist: A list of item types that cannot be placed in the inventory.
  • whitelist: A list of item types that can be placed in the inventory. When using this you cannot use the blacklist.

Creates an inventory for future use. This is not required for most functions.
The recommended use for this function is if you would like to place items into an inventory before opening it on the client.
Should be called server side.

Example - Server

TriggerEvent("Inventory:CreateAdvanced", "test", "Test", 5, 5, 10000.0)

Example 2 - Server

TriggerEvent("Inventory:CreateAdvanced", "onlyfood", "Test", 5, 5, 10000.0, nil, {"food"})
This example will only allow food in the inventory. Open the inventory "onlyfood" and test it.

Example 3 - Server

TriggerEvent("Inventory:CreateAdvanced", "nofood", "Test", 5, 5, 10000.0, {"food"})
This example will not allow food in the inventory. Open the inventory "nofood" and test it.

Inventory:DropItem(string item, Vector4 placement, string inventory, string slot, string myinventory = "")


Parameters:
  • item: ID of the item that has been dropped
  • placement: Location of the item (x,y,z,rot)
  • inventory: Inventory the item is coming from
  • slot: Slot the item is coming from (if applicable)
  • myinventory: Inventory of the player dropping the item

Fired from the client to the server when the client drops an item.
Calling this function will most likely result in a placed item without any emotes.
Should be watched server side.

Example - Server

AddEventHandler("Inventory:DropItem", function(item, placement, inventory, slot, myinventory)
  print("Somebody dropped an item! ID: "..item)
end)

Inventory:RemoveProximityInventory(string id)


Parameters:
  • id: Identifier of proximity inventory

Removes proximity inventory from environment.
Should be called server side.

Example - Server

TriggerEvent("Inventory:RemoveProximityInventory", "testproximity")

Inventory:UseItem(string itemId, string inventoryId, string slot)


Parameters:
  • itemId: Identifier of item
  • inventoryId: Identifier of containing inventory
  • slot: Identifier of containing slot

Called when an item is used. Is an internal function.
This is different than what is sent to the use event itself.
Is called from client to server

Inventory:UseItemSafe(string safeslotinventory, string itemId, string inventoryId, string slot)


Parameters:
  • safeslotinventory: Can only use item if it is in the first layer of this inventory.
  • itemId: Identifier of item
  • inventoryId: Identifier of containing inventory
  • slot: Identifier of containing slot

Called when an item is used. Is an internal function.
This is different than what is sent to the use event itself.
Is called from client to server

CreateSlotDrop(string slot, float x, float y, float z, string droptype = "manpurse")


Parameters:
  • slot: Identifier of the slot inventory.
  • x: Coordinates
  • y: Coordinates
  • z: Coordinates
  • droptype: Item to drop the items into

Creates an item that contains all of the items from the specified inventory.
Useful for zombie servers, etc, when the player drops loot on death.
Returns: Dropped Item ID (string)

Example - Client

local x,y,z, = table.unpack(GetEntityCoords(PlayerPedId()))
TriggerServerEvent("SlotDropExample", "playerinventory-"..exports['inventory']:GetCharId(), x,y,z)

Example - Server

RegisterNetEvent("SlotDropExample")
AddEventHandler("SlotDropExample", function(inventory, x,y,z)
  local drop = exports['inventory']:CreateSlotDrop(inventory, x,y,z)
  print('create drop with id: '..drop)
end)
Both parts of the example (client/server) need to be present to function properly

DeleteInventory(string inventory)


Parameters:
  • inventory: Identifier of the inventory.

Deletes inventory specified. There is no undo button
Returns: Success (true/false)

Example - Server

exports['inventory']:DeleteInventory("testinventory")

DeleteSlotInventory(string inventory)


Parameters:
  • inventory: Identifier of the slot inventory.

Deletes slot inventory specified. There is no undo button
Returns: Success (true/false)

Example - Server

exports['inventory']:DeleteSlotInventory("testinventory")

GetInventory(string inventory)


Parameters:
  • inventory: Identifier of the inventory.

Gets the entire inventory object.
Returns: JSON object (string)

Example - Server

print(exports['inventory']:GetInventory("testinventory"))

GetItemExtraData(string itemId, string key, string inventoryId = "", string slot = "")


Parameters:
  • itemId: Identifier of the item.
  • key: Identifier of the metadata requested.
  • inventoryId: Identifier of the inventory the item is in.
  • slot: Identifier of the slot the item is in.

Receives item metadata.
inventoryId and slot fields only required if the item is in a slot.
Returns: Speficied data (object)

Example - Server

local item = exports['inventory']:InventoryAddItem("pistol", "extradatatest")
local success = exports['inventory']:SetItemExtraData(item, "test", "example item metadata")
if success then 
  print("got data: "..exports['inventory']:GetItemExtraData(item, "test"))
else
  print("data was not set, maybe the item is invalid?")
end

InventoryAddItem(string item, string inventory)


Parameters:
  • item: Identifier of the item.
  • inventory: Inventory where the item goes.

Adds item to inventory
Returns: Item ID (string)

Example - Server

local item = exports['inventory']:InventoryAddItem("pistol", "test")

InventoryAddItemStack(string item, string inventory, int count)


Parameters:
  • item: Identifier of the item.
  • inventory: Inventory where the item goes.
  • count: Amount of items.

Adds items to inventory with a count
Returns: Status (true/false)

Example - Server

local success = exports['inventory']:InventoryAddItemStack("dollar", "test", 500)

InventoryCanFit(string item, string inventory)


Parameters:
  • item: Identifier of the item.
  • inventory: Inventory where the item goes.

Checks if item can fit in inventory
Returns: Status (true/false)

Example - Server

local canfit = exports['inventory']:InventoryCanFit("dollar", "test")

InventoryGetItem(string inventory, string item)


Parameters:
  • item: Type of the item.
  • inventory: Inventory to search.

Gets item in inventory based on the type
Returns: Item ID (string)

Example - Server

exports['inventory']:InventoryAddItem("pistol", "test")
Wait(1000) //give some time to update
local item = exports['inventory']:InventoryGetItem("test", "pistol")
print("found item :"..item)

InventoryHasItem(string inventory, string item)


Parameters:
  • item: Type of the item.
  • inventory: Inventory to search.

Gets item in inventory based on the type
Returns: Status (true/false)

Example - Server

local hasitem = exports['inventory']:InventoryHasItem("hasitemtest", "pistol")
if hasitem then print('has item') else print('does not have item') end

exports['inventory']:InventoryAddItem("pistol", "hasitemtest") Wait(1000) //give some time to update

local hasitem = exports['inventory']:InventoryHasItem("hasitemtest", "pistol")
if hasitem then print('has item') else print('does not have item') end

InventoryHasItemByID(string inventory, string item)


Parameters:
  • item: Unique ID of the item.
  • inventory: Inventory to search.

Gets item in inventory based on the type
Returns: Status (true/false)

Example - Server

local id = exports['inventory']:InventoryAddItem("pistol", "hasitembyidtest")
local fakeid = "1234FAKEID5678"
Wait(1000) //give some time to update

local hasitem = exports['inventory']:InventoryHasItemByID("hasitembyidtest", id)
local hasfakeitem = exports['inventory']:InventoryHasItemByID("hasitembyidtest", fakeid)

if hasitem then print('has item') else print('does not have item') end
if hasfakeitem then print('has fake item') else print('does not have fake item') end

InventoryItemCount(string inventory, string name)


Parameters:
  • name: Name of the item.
  • inventory: Inventory to search.

Gets item count in inventory based on the name
Returns: Count (int)

Example - Server

exports['inventory']:InventoryAddItemStack("dollar", "itemcounttest", 10)
Wait(100) //give some time to update
print('inventory has: '..exports['inventory']:InventoryItemCount("itemcounttest", "dollar")..' dollars')
exports['inventory']:InventoryAddItemStack("dollar", "itemcounttest", 100)
Wait(100)
print('inventory has: '..exports['inventory']:InventoryItemCount("itemcounttest", "dollar")..' dollars')

InventoryRemoveItem(string inventory, string name)


Parameters:
  • name: Name of the item.
  • inventory: Inventory to search.

Removes item from inventory based on name
Returns: Success (true/false)

Example - Server

local item = exports['inventory']:InventoryAddItem("pistol", "itemremovaltest")
Wait(100) //give some time to update
print('inventory has: '..exports['inventory']:InventoryItemCount("itemremovaltest", "pistol")..' pistols')
exports['inventory']:InventoryRemoveItem("itemremovaltest", "pistol")
Wait(100)
print('inventory has: '..exports['inventory']:InventoryItemCount("itemremovaltest", "pistol")..' pistols')

InventoryRemoveItemByID(string inventory, string id)


Parameters:
  • id: Unique ID of the item.
  • inventory: Inventory to remove from.

Removes item from inventory based on ID
Returns: Success (true/false)

Example - Server

local item = exports['inventory']:InventoryAddItem("pistol", "itemremovaltest")
Wait(100) //give some time to update
print('inventory has: '..exports['inventory']:InventoryItemCount("itemremovaltestbyid", "pistol")..' pistols')
exports['inventory']:InventoryRemoveItemByID("itemremovaltest", item)
Wait(100)
print('inventory has: '..exports['inventory']:InventoryItemCount("itemremovaltestbyid", "pistol")..' pistols')

SetItemExtraData(string itemId, string key, object value, string inventoryId = "", string slot = "")


Parameters:
  • itemId: Identifier of the item.
  • key: Identifier of the metadata.
  • value: Value to set into the items metadata.
  • inventoryId: Identifier of the inventory the item is in.
  • slot: Identifier of the slot the item is in.

Sets item metadata.
inventoryId and slot fields only required if the item is in a slot.
Returns: Success (true/false)

Example - Server

local item = exports['inventory']:InventoryAddItem("pistol", "extradatatest")
local success = exports['inventory']:SetItemExtraData(item, "test", "example item metadata")
if success then 
  print("got data: "..exports['inventory']:GetItemExtraData(item, "test"))
else
  print("data was not set, maybe the item is invalid?")
end

SlotInventoryAddItem(string item, string inventory)


Parameters:
  • item: Identifier of the item.
  • inventory: Inventory where the item goes.

Adds item into the first layer interior inventories of a slot inventory
IE: Adding to a player - if the player has a bag it will place it in the bag
If the slot inventory does not have any items with interiors the item will not be added.
Returns: Item ID (string)

Example - Server

//this is not a valid player inventory, you can check your identifier with the GetCharID export (client)
local item = exports['inventory']:SlotInventoryAddItem("pistol", "playerinventory-12345")

SlotInventoryAddItemPreferSlot(string item, string inventory, string slot)


Parameters:
  • item: Identifier of the item.
  • inventory: Inventory where the item goes.
  • slot: Preferred slot for the item to go.

Adds item into the first layer interior inventories of a slot inventory
This was orignally created as a request in assistance to a wallet slot the client had added to the player inventory
It will try to add the item into the interior of the specified slot before any other, if it fails it will place in an open space
IE: Adding to a player - if the player has a bag it will place it in the bag
If the slot inventory does not have any items with interiors the item will not be added.
Returns: Item ID (string)

Example - Server

//this is not a valid player inventory, you can check your identifier with the GetCharID export (client)
local id = "12345"
local item = exports['inventory']:SlotInventoryAddItemPreferSlot("pistol", "playerinventory-"..id, "player-backpack")

SlotInventoryAddItemStack(string item, string inventory, int count)


Parameters:
  • item: Identifier of the item.
  • inventory: Inventory where the item goes.
  • count: Amount of items.

Adds items to slot inventory with a count
Returns: Status (true/false)

Example - Server

//this is not a valid player inventory, you can check your identifier with the GetCharID export (client)
local identifier = "12345"
local success = exports['inventory']:SlotInventoryAddItemStack("dollar", "playerinventory-"..identifier, 500)

SlotInventoryAddItemToSlot(string item, string inventory, string slot)


Parameters:
  • item: Identifier of the item.
  • inventory: Inventory where the item goes.
  • slot: Slot to set the item.

Adds item into slot of slot inventory
IE: Puts shirt into the shirt slot

Warning: there is no check for what type of item you are adding into the slot
This means you can add a banana into the shirt slot and it will work
Returns: Item ID (string)

Example - Server

//this will add a duffel to the player
//this is not a valid player inventory, you can check your identifier with the GetCharID export (client)
local identifier = "12345"
local success = exports['inventory']:SlotInventoryAddItemToSlot("clothing_5_41_0", "playerinventory-"..identifier, "player-backpack")

SlotInventoryItemCount(string slotinventory, string item)


Parameters:
  • item: Identifier of the item.
  • slotinventory: Inventory to search.

Returns count of item inside slot inventory contents.
Returns: Count (int)

Example - Server

//this is not a valid player inventory, you can check your identifier with the GetCharID export (client)
local identifier = "12345"
local success = exports['inventory']:SlotInventoryItemCount("playerinventory-"..identifier, "dollar")

SlotInventoryRemoveItem(string slotinventory, string item, int count = 1)


Parameters:
  • slotinventory: Inventory to remove from.
  • item: Identifier of the item.
  • count: Amount of items to remove.

Removes item from slot inventory contents.
Returns: Success (true/false)

Example - Server

//this is not a valid player inventory, you can check your identifier with the GetCharID export (client)
local identifier = "12345"
local success = exports['inventory']:SlotInventoryRemoveItem("playerinventory-"..identifier, "dollar") //removes 1 dollar
local success = exports['inventory']:SlotInventoryRemoveItem("playerinventory-"..identifier, "dollar", 100) //removes 100 dollars