Introduction
Welcome to the Avalanche Productions Inventory documentation.
This comprehensive guide covers everything you need to know about installing, configuring, and integrating the inventory system into your FiveM server.
Features
- Grid-Based Inventory - Drag and drop items with configurable dimensions
- Slot-Based Equipment - Dedicated slots for clothing, weapons, and accessories
- Weight System - Realistic weight management for items and inventories
- Durability System - Items can degrade over time with use
- Temperature System - Items can heat up or cool down
- Stackable Items - Combine identical items into stacks
- Container Items - Items that contain their own inventory
- Ground Items - Drop items in the world for others to pick up
- Vehicle Inventories - Trunk and glovebox storage
- Proximity Inventories - Access inventories within range
- Clothing System - Full GTA Online clothing support
- Weapon System - Attachments, ammo management, and durability
- Custom Events - Hook into item use, equip, and creation events
Quick Start
- Place the
inventoryfolder in your server resources directory - Add
ensure inventoryto your server.cfg - Add your Tebex key to
key.txt - Configure the
GetCharIdfunction inclient.luafor your identifier system - Start your server
Support
For support, join our Discord server.
Last updated: December 2025
Requirements
Server Requirements
- FiveM server with up-to-date artifacts
- MySQL database (MySQL 5.7+ or MariaDB 10.2+)
- Valid Tebex license key
Framework Compatibility
The inventory system is standalone and does not require ESX, QBCore, or any other framework. However, it can integrate with any framework.
Identifier Setup
The inventory uses a unique character identifier for player inventories. You must configure the GetCharId function in client.lua to return your character identifier.
ESX Example:
function GetCharId()
local ESX = exports['es_extended']:getSharedObject()
return ESX.GetPlayerData().identifier
end
QBCore Example:
function GetCharId()
local QBCore = exports['qb-core']:GetCoreObject()
local PlayerData = QBCore.Functions.GetPlayerData()
return PlayerData.citizenid
end
Steam ID Example:
function GetCharId()
return GetPlayerIdentifierByType(PlayerId(), 'steam')
end
Multicharacter Example:
function GetCharId()
-- Return your multichar system's character ID
return exports['your-multichar']:GetCurrentCharacterId()
end
Database
The inventory automatically creates its required tables on first startup. Ensure your MySQL connection is configured in your server.cfg:
set mysql_connection_string "mysql://user:password@localhost/database?charset=utf8mb4"
Clothing Support
All GTA Online clothing is pre-defined up to game build 2060 (The Diamond Casino Heist). Clothing from newer DLCs may need to be added manually to the definitions.
Installation
Basic Installation
-
Extract the Resource
- Place the
inventoryfolder into your server's resources directory
- Place the
-
Configure Server
- Add
ensure inventoryto yourserver.cfg - Ensure it starts after your MySQL resource
- Add
-
Add License Key
- Place your Tebex Purchase ID or key into
key.txt
- Place your Tebex Purchase ID or key into
-
Configure Identifier
- Edit
client.luaand configure theGetCharIdfunction for your identifier system - See Requirements for examples
- Edit
-
Start Server
- Start your server and verify the inventory loads without errors
Store Installation (Optional)
Two clothing store options are included with the inventory.
Store Beta (Recommended)
The store-beta resource provides a complete clothing store system:
- Pre-configured with all vanilla store coordinates
- Randomly generates clothing at different price points
- Supports all clothing up to game build 2060
- Press E at any clothing store marker to access
To install:
ensure store-beta
Legacy Store
The original store resource is also included for backwards compatibility.
ESX Integration (Optional)
By default, the inventory is configured for ESX. If using ESX:
- Ensure ESX is started before the inventory
- The
GetCharIdfunction is pre-configured to use ESX identifiers - Items placed in player inventory will automatically equip to clothing slots
Verification
After installation, verify everything is working:
- Join your server
- Press your inventory key (default: TAB)
- The inventory UI should appear
- Check server console for any errors
Troubleshooting
Inventory doesn't open:
- Check that the resource started without errors
- Verify your license key is correct in
key.txt - Ensure the
GetCharIdfunction returns a valid identifier
Database errors:
- Verify your MySQL connection string
- Check that the database user has CREATE TABLE permissions
- Ensure the database character set supports utf8mb4
Clothing not showing:
- Verify clothing definitions exist for the items
- Check that clothing components match your ped model
Configuration
The inventory system is configured through JSON files in the definitions folder.
Configuration Files
| File | Purpose |
|---|---|
definitions/items/*.json |
Item definitions |
definitions/inventories.json |
Inventory size presets |
definitions/slotinventories.json |
Slot inventory layouts |
definitions/generation.json |
Random item generation rules |
definitions/rarity.json |
Item rarity weights |
Inventory Sizes
Define preset inventory dimensions in inventories.json:
{
"default": {
"Height": 5,
"Width": 10,
"Weight": 50000
},
"small": {
"Height": 3,
"Width": 5,
"Weight": 10000
},
"vehicle-trunk": {
"Height": 5,
"Width": 8,
"Weight": 100000
}
}
Properties
| Property | Type | Description |
|---|---|---|
Height |
int | Number of rows in the inventory grid |
Width |
int | Number of columns in the inventory grid |
Weight |
float | Maximum weight capacity (in grams) |
WhitelistedTypes |
string[] | Only allow these item types (optional) |
BlacklistedTypes |
string[] | Block these item types (optional) |
Item Generation
Configure random loot generation in generation.json:
{
"trash-can": {
"Dimensions": {
"Height": 2,
"Width": 3,
"Weight": 5000
},
"Types": ["trash", "junk"],
"AcceptableAmounts": [1, 2, 3]
}
}
Properties
| Property | Type | Description |
|---|---|---|
Dimensions |
object | Inventory size for generated loot |
Types |
string[] | Item groups to pull from (see rarity.json) |
AcceptableAmounts |
int[] | Pool for how many items to generate |
Item Rarity
Configure item spawn weights in rarity.json:
[
{
"ItemId": "water",
"Weight": 100,
"Gradient": [1, 3],
"Groups": ["food", "common"]
},
{
"ItemId": "gold_bar",
"Weight": 5,
"Gradient": [1, 1],
"Groups": ["valuable", "rare"]
}
]
Properties
| Property | Type | Description |
|---|---|---|
ItemId |
string | The item type to spawn |
Weight |
int | Spawn weight (higher = more common) |
Gradient |
int[] | Range for quantity [min, max] |
Groups |
string[] | Categories for generation filters |
The rarity system is weight-based. If you have items with weights 100, 50, and 5, the total pool is 155. The chance of each item is its weight divided by the total (e.g., 100/155 = 64.5%).
Item Definitions
Items are defined in JSON files within the definitions/items/ folder. Each item definition describes how an item looks, behaves, and interacts with the inventory system.
Basic Item Structure
{
"Name": "water",
"FriendlyName": "Water Bottle",
"Icon": "img/items/water.png",
"ItemTypes": ["consumable", "drink"],
"Stackable": true,
"MaxStack": 10,
"InitialWeight": 500,
"ExteriorDimensions": {
"Width": 1,
"Height": 1
}
}
All Properties
Identity
| Property | Type | Required | Description |
|---|---|---|---|
Name |
string | Yes | Unique identifier for the item (used in code) |
FriendlyName |
string | Yes | Display name shown in UI |
Icon |
string | Yes | Path to item icon image |
ItemDescription |
string | No | Description text shown in item tooltip |
Classification
| Property | Type | Default | Description |
|---|---|---|---|
ItemTypes |
string[] | [] |
Categories for filtering and slot acceptance |
ContextTags |
string[] | [] |
Additional tags for UI organization |
Behavior
| Property | Type | Default | Description |
|---|---|---|---|
Stackable |
bool | false |
Whether identical items can stack together |
MaxStack |
int | 100 |
Maximum stack size (if stackable) |
Weapon |
bool | false |
Whether this is a weapon item |
RemoveOnUse |
bool | false |
Delete item when used |
Repairable |
bool | false |
Whether item can be repaired |
Physical Properties
| Property | Type | Default | Description |
|---|---|---|---|
InitialWeight |
float | 0 |
Base weight in grams |
ExteriorDimensions |
object | Required | Grid size the item occupies |
ExteriorDimensions:
"ExteriorDimensions": {
"Width": 2,
"Height": 1
}
Durability System
| Property | Type | Default | Description |
|---|---|---|---|
MaxDurability |
double | 0 |
Maximum durability value (0 = no durability) |
EquipDurabilityLoss |
double | 0 |
Durability lost each time equipped |
UseDurabilityLoss |
double | 0 |
Durability lost each time used |
DisplayDurability |
bool | false |
Show durability bar in UI |
Temperature System
| Property | Type | Default | Description |
|---|---|---|---|
InitialTemperature |
float | 70.0 |
Starting temperature (Fahrenheit) |
MeltingPoint |
double | 0 |
Temperature at which item melts/spoils |
HeatAbsorptionRate |
double | 0 |
Rate of temperature change |
Container Properties
Items can contain their own inventory or slot layout.
| Property | Type | Description |
|---|---|---|
InteriorDimensions |
object | Grid inventory inside the item |
SlotInventoryDefinition |
string | Reference to a slot inventory type |
FillType |
string | Special fill behavior for generation |
InteriorDimensions Example (Bag):
{
"Name": "backpack",
"FriendlyName": "Backpack",
"InteriorDimensions": {
"Height": 4,
"Width": 6,
"Weight": 20000,
"BlacklistedTypes": ["bag"]
}
}
SlotInventoryDefinition Example (Weapon):
{
"Name": "weapon_pistol",
"FriendlyName": "Pistol",
"SlotInventoryDefinition": "Pistol"
}
Visual Properties
| Property | Type | Description |
|---|---|---|
Prop |
object | Model and attachment configuration |
SpecialDisplay |
string | Special rendering mode |
Metadata
| Property | Type | Description |
|---|---|---|
ExtraData |
object | Default custom data for new items |
Events |
object | Event triggers for item actions |
DescriptionInformation |
object | Dynamic description fields |
Prop Configuration
The Prop property defines how items appear when held or attached to the player.
{
"Name": "flashlight",
"Prop": {
"Prop": "prop_flashlight_01",
"HoldingAnimation": "yourdict@youranim",
"Attach": true,
"AttachInformation": [57005, 0.1, 0.02, 0.0, 0.0, 0.0, 0.0],
"FakeWeapon": "WEAPON_FLASHLIGHT"
}
}
Prop Properties
| Property | Type | Description |
|---|---|---|
Prop |
string | GTA prop model name |
HoldingAnimation |
string | Animation dictionary@clip to play |
Attach |
bool | Attach to player bone |
AttachInformation |
float[] | [boneId, x, y, z, rx, ry, rz] |
FakeWeapon |
string | Weapon hash for aiming (if applicable) |
NonHandAttachments |
object | Attachments for non-hand slots |
Bone IDs
Common bone IDs for attachments:
57005- Right hand18905- Left hand24818- Right thigh58271- Spine39317- Back
Item Events
Items can trigger custom events when created, equipped, or used.
{
"Name": "medkit",
"Events": {
"use-server": "medical:useMedkit",
"use-client": "medical:playAnimation"
}
}
Available Events
| Event | Trigger | Description |
|---|---|---|
create |
Item created | Fired when a new item instance is created |
equip-server |
Item equipped (server) | Fired when item is placed in hand slot |
equip-client |
Item equipped (client) | Client-side equip notification |
deequip-server |
Item unequipped (server) | Fired when item is removed from hand slot |
deequip-client |
Item unequipped (client) | Client-side unequip notification |
use-server |
Item used (server) | Fired when item is used/consumed |
use-client |
Item used (client) | Client-side use notification |
Event Parameters
Client Events receive:
itemId(string) - Unique item instance ID
Server Events receive:
source(int) - Player server IDitemId(string) - Unique item instance IDinventoryId(string) - Containing inventory IDslot(string) - Containing slot (if applicable)
Event Example
-- Server-side event handler
RegisterNetEvent('medical:useMedkit', function(source, itemId, inventoryId, slot)
local health = GetEntityHealth(GetPlayerPed(source))
SetEntityHealth(GetPlayerPed(source), math.min(200, health + 50))
end)
-- Client-side event handler
RegisterNetEvent('medical:playAnimation', function(itemId)
-- Play healing animation
TaskPlayAnim(PlayerPedId(), "amb@medic@standing@tendtodead@idle_a", "idle_a", 8.0, 8.0, -1, 1, 0, false, false, false)
end)
Complete Examples
Consumable Item
{
"Name": "burger",
"FriendlyName": "Burger",
"Icon": "img/items/burger.png",
"ItemDescription": "A delicious burger that restores hunger.",
"ItemTypes": ["consumable", "food"],
"Stackable": true,
"MaxStack": 5,
"RemoveOnUse": true,
"InitialWeight": 250,
"ExteriorDimensions": {
"Width": 1,
"Height": 1
},
"Events": {
"use-server": "hunger:eatFood",
"use-client": "hunger:playEatAnimation"
}
}
Weapon Item
{
"Name": "weapon_pistol",
"FriendlyName": "Pistol",
"Icon": "img/weapons/pistol.png",
"ItemTypes": ["weapon", "handgun"],
"Weapon": true,
"Stackable": false,
"InitialWeight": 1500,
"MaxDurability": 1000,
"UseDurabilityLoss": 1,
"DisplayDurability": true,
"ExteriorDimensions": {
"Width": 2,
"Height": 1
},
"SlotInventoryDefinition": "Pistol",
"Events": {
"equip-server": "Inventory:RefreshWeapon",
"deequip-client": "Inventory:RemoveWeapon"
},
"ExtraData": {
"weapon": "WEAPON_PISTOL"
}
}
Container Item (Bag)
{
"Name": "dufflebag",
"FriendlyName": "Duffle Bag",
"Icon": "img/items/dufflebag.png",
"ItemTypes": ["bag", "container"],
"Stackable": false,
"InitialWeight": 500,
"ExteriorDimensions": {
"Width": 3,
"Height": 2
},
"InteriorDimensions": {
"Height": 5,
"Width": 8,
"Weight": 50000,
"BlacklistedTypes": ["bag"]
},
"Prop": {
"Prop": "prop_michael_backpack",
"Attach": true,
"AttachInformation": [24818, 0.0, -0.1, 0.0, 0.0, 0.0, 0.0]
}
}
Clothing Item
{
"Name": "tshirt_black",
"FriendlyName": "Black T-Shirt",
"Icon": "img/clothing/tshirt_black.png",
"ItemTypes": ["clothing", "torso"],
"Stackable": false,
"InitialWeight": 200,
"ExteriorDimensions": {
"Width": 2,
"Height": 2
},
"ExtraData": {
"component": 11,
"drawable": 15,
"texture": 0
}
} Inventory Definitions
Slot inventories define equipment layouts with designated slots for specific item types. They're used for player equipment, weapon attachments, vehicle storage, and more.
Slot Inventory Structure
Slot inventories are defined in definitions/slotinventories.json:
{
"Player": {
"Title": "Equipment",
"Windowed": false,
"Left": 50,
"Top": 100,
"Width": 300,
"Height": 400,
"DisplayTitle": true,
"Slots": {
"head": {
"Title": "Head",
"Width": 2,
"Height": 2,
"Left": 10,
"Top": 10,
"Accepts": ["hat", "helmet", "mask"],
"Icon": "img/slots/head.png"
}
}
}
}
Slot Inventory Properties
| Property | Type | Default | Description |
|---|---|---|---|
Title |
string | Required | Display name for the inventory window |
Windowed |
bool | false |
Whether the inventory appears in a moveable window |
Left |
int | 0 |
Horizontal position offset (pixels) |
Top |
int | 0 |
Vertical position offset (pixels) |
Width |
int | auto |
Window width (if windowed) |
Height |
int | auto |
Window height (if windowed) |
DisplayTitle |
bool | true |
Whether to show the title bar |
BackgroundImage |
string | null |
Background image path (windowed only) |
Slots |
object | Required | Slot definitions |
Buttons |
array | [] |
Action buttons |
Inputs |
array | [] |
Input fields |
Slot Definition
Each slot within a slot inventory:
{
"head": {
"Title": "Head",
"Width": 2,
"Height": 2,
"Left": 10,
"Top": 10,
"Accepts": ["hat", "helmet", "mask"],
"Icon": "img/slots/head.png"
}
}
Slot Properties
| Property | Type | Default | Description |
|---|---|---|---|
Title |
string | Slot key | Display name for the slot |
Width |
int | 1 |
Slot grid width |
Height |
int | 1 |
Slot grid height |
Left |
int | Required | Horizontal position within inventory |
Top |
int | Required | Vertical position within inventory |
Accepts |
string[] | [] |
Item types this slot accepts (empty = all) |
Icon |
string | null |
Placeholder icon when empty |
Button Configuration
Add interactive buttons to slot inventories:
{
"Buttons": [
{
"Id": "save-outfit",
"Label": "Save Outfit",
"Left": 10,
"Top": 350,
"Event": "clothing:saveOutfit",
"EventType": "server"
}
]
}
Button Properties
| Property | Type | Description |
|---|---|---|
Id |
string | Unique button identifier |
Label |
string | Button text |
Left |
int | Horizontal position |
Top |
int | Vertical position |
Event |
string | Event to trigger on click |
EventType |
string | "server" or "client" |
Input Configuration
Add text input fields to slot inventories:
{
"Inputs": [
{
"Id": "outfit-name",
"Label": "Outfit Name",
"Left": 10,
"Top": 320,
"Width": 200
}
]
}
Input Properties
| Property | Type | Description |
|---|---|---|
Id |
string | Unique input identifier |
Label |
string | Input label |
Left |
int | Horizontal position |
Top |
int | Vertical position |
Width |
int | Input field width |
Complete Examples
Player Equipment
{
"Player": {
"Title": "Equipment",
"Windowed": false,
"Left": 50,
"Top": 50,
"DisplayTitle": false,
"Slots": {
"hat": {
"Title": "Hat",
"Width": 2,
"Height": 2,
"Left": 100,
"Top": 0,
"Accepts": ["hat", "helmet"],
"Icon": "img/slots/hat.png"
},
"glasses": {
"Title": "Glasses",
"Width": 2,
"Height": 1,
"Left": 100,
"Top": 50,
"Accepts": ["glasses"],
"Icon": "img/slots/glasses.png"
},
"mask": {
"Title": "Mask",
"Width": 2,
"Height": 2,
"Left": 0,
"Top": 0,
"Accepts": ["mask"],
"Icon": "img/slots/mask.png"
},
"torso": {
"Title": "Torso",
"Width": 2,
"Height": 3,
"Left": 50,
"Top": 80,
"Accepts": ["torso", "shirt", "jacket"],
"Icon": "img/slots/torso.png"
},
"legs": {
"Title": "Legs",
"Width": 2,
"Height": 3,
"Left": 50,
"Top": 170,
"Accepts": ["legs", "pants"],
"Icon": "img/slots/legs.png"
},
"shoes": {
"Title": "Shoes",
"Width": 2,
"Height": 2,
"Left": 50,
"Top": 260,
"Accepts": ["shoes", "boots"],
"Icon": "img/slots/shoes.png"
},
"bag": {
"Title": "Bag",
"Width": 3,
"Height": 2,
"Left": 150,
"Top": 100,
"Accepts": ["bag", "backpack"],
"Icon": "img/slots/bag.png"
},
"hand": {
"Title": "Hand",
"Width": 3,
"Height": 2,
"Left": 0,
"Top": 150,
"Accepts": [],
"Icon": "img/slots/hand.png"
}
}
}
}
Weapon Attachments (Pistol)
{
"Pistol": {
"Title": "Pistol",
"Windowed": true,
"Left": 400,
"Top": 100,
"Width": 250,
"Height": 200,
"Slots": {
"magazine": {
"Title": "Magazine",
"Width": 1,
"Height": 2,
"Left": 10,
"Top": 10,
"Accepts": ["ammo_pistol"],
"Icon": "img/slots/magazine.png"
},
"suppressor": {
"Title": "Suppressor",
"Width": 2,
"Height": 1,
"Left": 60,
"Top": 10,
"Accepts": ["suppressor"],
"Icon": "img/slots/suppressor.png"
},
"flashlight": {
"Title": "Flashlight",
"Width": 2,
"Height": 1,
"Left": 60,
"Top": 60,
"Accepts": ["flashlight"],
"Icon": "img/slots/flashlight.png"
}
}
}
}
Vehicle Trunk
{
"VehicleTrunk": {
"Title": "Trunk",
"Windowed": true,
"Left": 600,
"Top": 100,
"Width": 400,
"Height": 300,
"Slots": {
"main": {
"Title": "Storage",
"Width": 8,
"Height": 5,
"Left": 10,
"Top": 10,
"Accepts": [],
"Icon": null
}
}
}
}
Custom Container with Background
{
"Safe": {
"Title": "Personal Safe",
"Windowed": true,
"Left": 300,
"Top": 150,
"Width": 350,
"Height": 400,
"BackgroundImage": "img/backgrounds/safe.png",
"DisplayTitle": true,
"Slots": {
"main": {
"Title": "Contents",
"Width": 6,
"Height": 8,
"Left": 25,
"Top": 25,
"Accepts": []
}
},
"Buttons": [
{
"Id": "change-code",
"Label": "Change Code",
"Left": 25,
"Top": 350,
"Event": "safe:changeCode",
"EventType": "server"
}
],
"Inputs": [
{
"Id": "new-code",
"Label": "New Code",
"Left": 150,
"Top": 350,
"Width": 150
}
]
}
}
Linking Items to Slot Inventories
To make an item use a slot inventory, set the SlotInventoryDefinition property in the item definition:
{
"Name": "weapon_pistol",
"FriendlyName": "Pistol",
"SlotInventoryDefinition": "Pistol"
}
When the player accesses this item's interior, it will display the "Pistol" slot inventory layout instead of a grid inventory.
Client Events
These are events triggered FROM the server TO the client. Listen for them using RegisterNetEvent().
UI Events
Inventory:Toggle
Toggle the inventory UI open or closed.
| Parameter | Type | Description |
|---|---|---|
closeOnly |
bool | If true, only closes (won't open) |
RegisterNetEvent('Inventory:Toggle', function(closeOnly)
-- Inventory UI toggled
end)
Inventory:ForceClose
Force close the inventory UI.
| Parameter | Type | Description |
|---|---|---|
reason |
string | Reason for closing (optional) |
RegisterNetEvent('Inventory:ForceClose', function(reason)
-- Inventory was force closed
end)
Inventory:Update
Refresh the display for a specific inventory.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | The inventory to refresh |
RegisterNetEvent('Inventory:Update', function(inventoryId)
-- Inventory display refreshed
end)
Inventory:SlotUpdate
Refresh a slot-based inventory display.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | The slot inventory to refresh |
RegisterNetEvent('Inventory:SlotUpdate', function(inventoryId)
-- Slot inventory display refreshed
end)
Inventory:Notify
Display a notification to the player.
| Parameter | Type | Description |
|---|---|---|
message |
string | Notification message |
RegisterNetEvent('Inventory:Notify', function(message)
-- Display notification
end)
Item Events
Inventory:HoldItem
Attach an item prop to the player's hands with animation.
| Parameter | Type | Description |
|---|---|---|
item |
string | Item name |
prop |
string | Prop model name |
animation |
string | Animation dict@clip |
bone |
int | Bone ID for attachment |
x, y, z |
float | Position offset |
rx, ry, rz |
float | Rotation offset |
fakeweapon |
string | Fake weapon hash (optional) |
RegisterNetEvent('Inventory:HoldItem', function(item, prop, animation, bone, x, y, z, rx, ry, rz, fakeweapon)
-- Item attached to player
end)
Inventory:RemoveHeldItem
Remove the currently held item prop.
RegisterNetEvent('Inventory:RemoveHeldItem', function()
-- Held item removed
end)
Inventory:RemoveAttachedItem
Remove an attached item from a specific bone.
| Parameter | Type | Description |
|---|---|---|
bone |
int | Bone ID to remove from |
RegisterNetEvent('Inventory:RemoveAttachedItem', function(bone)
-- Attachment removed from bone
end)
Inventory:SetEquippedItem
Update the UI to show which item is equipped.
| Parameter | Type | Description |
|---|---|---|
itemName |
string | Name of equipped item |
RegisterNetEvent('Inventory:SetEquippedItem', function(itemName)
-- Equipped item UI updated
end)
Inventory:RequestAccess
Another player is requesting access to your inventory.
| Parameter | Type | Description |
|---|---|---|
requesterId |
int | Server ID of requesting player |
RegisterNetEvent('Inventory:RequestAccess', function(requesterId)
-- Handle access request (show prompt, etc.)
end)
Weapon Events
Inventory:GiveWeapon
Give a weapon to the player.
| Parameter | Type | Description |
|---|---|---|
weaponName |
string | Weapon hash name |
RegisterNetEvent('Inventory:GiveWeapon', function(weaponName)
-- Weapon given to player
end)
Inventory:RemoveWeapon
Remove all weapons from the player.
RegisterNetEvent('Inventory:RemoveWeapon', function()
-- Weapons removed
end)
Inventory:SetAmmo
Set ammunition count for equipped weapon.
| Parameter | Type | Description |
|---|---|---|
amount |
int | Ammo count |
reload |
bool | Whether to reload the weapon |
RegisterNetEvent('Inventory:SetAmmo', function(amount, reload)
-- Ammo updated
end)
Inventory:GiveWeaponAttachment
Add an attachment to a weapon.
| Parameter | Type | Description |
|---|---|---|
weaponName |
string | Weapon hash name |
componentName |
string | Component hash name |
RegisterNetEvent('Inventory:GiveWeaponAttachment', function(weaponName, componentName)
-- Attachment added
end)
Inventory:GiveParachute
Give the player a parachute.
| Parameter | Type | Description |
|---|---|---|
functional |
bool | Whether parachute works |
tint |
int | Parachute tint index |
RegisterNetEvent('Inventory:GiveParachute', function(functional, tint)
-- Parachute given
end)
Inventory:RemoveParachute
Remove parachute from player.
RegisterNetEvent('Inventory:RemoveParachute', function()
-- Parachute removed
end)
Clothing Events
Clothing:LoadComponent
Load a clothing component on the player.
| Parameter | Type | Description |
|---|---|---|
componentId |
int | Component slot (0-11) |
drawableId |
int | Drawable variation |
textureId |
int | Texture variation |
modelName |
string | Ped model name |
ped |
int | Ped entity handle |
RegisterNetEvent('Clothing:LoadComponent', function(componentId, drawableId, textureId, modelName, ped)
-- Clothing component applied
end)
Clothing:LoadProp
Load a prop/accessory on the player.
| Parameter | Type | Description |
|---|---|---|
propId |
int | Prop slot (0-8) |
drawableId |
int | Drawable variation |
textureId |
int | Texture variation |
modelName |
string | Ped model name |
ped |
int | Ped entity handle |
RegisterNetEvent('Clothing:LoadProp', function(propId, drawableId, textureId, modelName, ped)
-- Prop applied
end)
Clothing:ClearProps
Remove all props/accessories from player.
RegisterNetEvent('Clothing:ClearProps', function()
-- All props cleared
end)
Clothing:FixTorso
Fix torso appearance after clothing changes.
| Parameter | Type | Description |
|---|---|---|
value |
int | Torso variant |
RegisterNetEvent('Clothing:FixTorso', function(value)
-- Torso fixed
end)
Clothing:UpdateDisplayPed
Update the display ped in UI preview.
RegisterNetEvent('Clothing:UpdateDisplayPed', function()
-- Display ped updated
end)
Ground Item Events
Inventory:UpdatePlacedItemData
Update ground item visual data.
| Parameter | Type | Description |
|---|---|---|
location |
vector4 | Position and heading |
model |
string | Prop model name |
itemId |
string | Unique item ID |
expiration |
int | Expiration timestamp |
placeProperly |
bool | Use proper placement |
collision |
bool | Enable collision |
RegisterNetEvent('Inventory:UpdatePlacedItemData', function(location, model, itemId, expiration, placeProperly, collision)
-- Ground item updated
end)
Inventory:RemoveItemAtCoords
Remove a ground item at specific coordinates.
| Parameter | Type | Description |
|---|---|---|
location |
vector4 | Position and heading |
model |
string | Prop model name |
RegisterNetEvent('Inventory:RemoveItemAtCoords', function(location, model)
-- Ground item removed
end)
Inventory:ListPlacedItems
Receive list of nearby ground items.
| Parameter | Type | Description |
|---|---|---|
jsonData |
string | JSON array of placed items |
RegisterNetEvent('Inventory:ListPlacedItems', function(jsonData)
local items = json.decode(jsonData)
-- Process ground items
end)
Inventory:PlacedItemUpdate
Trigger re-request of placed items at current location.
RegisterNetEvent('Inventory:PlacedItemUpdate', function()
-- Request fresh placed item data
end)
Inventory:RemovePlacedItemData
Clear all ground item data from memory.
RegisterNetEvent('Inventory:RemovePlacedItemData', function()
-- Placed item cache cleared
end)
Network Object Events
Inventory:AddNetworkObjectClient
Register a network object as having an inventory.
| Parameter | Type | Description |
|---|---|---|
networkObject |
int | Network object handle |
inventoryId |
string | Linked inventory ID |
RegisterNetEvent('Inventory:AddNetworkObjectClient', function(networkObject, inventoryId)
-- Network object registered
end)
Inventory:RemoveNetworkObjectClient
Unregister a network object's inventory.
| Parameter | Type | Description |
|---|---|---|
networkObject |
int | Network object handle |
RegisterNetEvent('Inventory:RemoveNetworkObjectClient', function(networkObject)
-- Network object unregistered
end)
Inventory:OpenNetworkObject
Open the inventory of a network object.
| Parameter | Type | Description |
|---|---|---|
networkObject |
int | Network object handle |
RegisterNetEvent('Inventory:OpenNetworkObject', function(networkObject)
-- Opening network object inventory
end)
Utility Events
Inventory:TryEquip
Attempt to equip an item (shows feedback).
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Source inventory |
itemId |
string | Item to equip |
slot |
string | Target slot |
RegisterNetEvent('Inventory:TryEquip', function(inventoryId, itemId, slot)
-- Equip attempt
end)
Inventory:ForceDropItem
Force the player to drop currently held item.
RegisterNetEvent('Inventory:ForceDropItem', function()
-- Force drop held item
end)
Inventory:DeleteDrop
Delete the drop preview being placed.
RegisterNetEvent('Inventory:DeleteDrop', function()
-- Drop preview cancelled
end)
Inventory:SetConfigVariable
Update a configuration variable on client.
| Parameter | Type | Description |
|---|---|---|
key |
string | Config key |
value |
any | Config value |
RegisterNetEvent('Inventory:SetConfigVariable', function(key, value)
-- Config updated
end) Client Exports
These exports are available on the client-side. Call them using exports['inventory']:ExportName().
DoesNetworkObjectHaveInventory
Check if a network object has an inventory attached.
Parameters:
| Name | Type | Description |
|---|---|---|
obj |
int | Network object entity handle |
Returns: bool - Whether the object has an inventory
local hasInventory = exports['inventory']:DoesNetworkObjectHaveInventory(object)
if hasInventory then
-- Object has an inventory we can access
end
GetStatus
Get whether the inventory UI is currently open.
Parameters: None
Returns: bool - true if inventory is open, false otherwise
local isOpen = exports['inventory']:GetStatus()
if isOpen then
-- Inventory UI is open
else
-- Inventory UI is closed
end
Example - Prevent action while inventory open:
RegisterCommand('action', function()
if exports['inventory']:GetStatus() then
TriggerEvent('chat:addMessage', { args = { 'Close your inventory first!' } })
return
end
-- Perform action
end)
GetEquippedItem
Get the name of the currently equipped/held item.
Parameters: None
Returns: string - Item name, or nil if nothing equipped
local equippedItem = exports['inventory']:GetEquippedItem()
if equippedItem then
print('Currently holding: ' .. equippedItem)
else
print('Hands are empty')
end
Example - Check if player is armed:
local item = exports['inventory']:GetEquippedItem()
if item and string.find(item, 'weapon_') then
-- Player is holding a weapon
end Server Events
These are events you trigger FROM the client or server TO the inventory system. Use TriggerServerEvent() from client or TriggerEvent() from server.
Inventory Access Events
Inventory:Access
Open an inventory for a player.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Unique inventory identifier |
type |
string | Inventory size preset (from inventories.json) |
-- Client-side
TriggerServerEvent('Inventory:Access', 'stash-123', 'default')
-- Server-side
TriggerClientEvent('openinventory', source, 'stash-123', 'Stash')
Inventory:AccessForce
Force open an inventory on a specific player (admin use).
| Parameter | Type | Description |
|---|---|---|
playerId |
int | Target player server ID |
inventoryId |
string | Inventory to open |
type |
string | Inventory size preset |
-- Server-side only
TriggerEvent('Inventory:AccessForce', targetPlayerId, 'stash-admin', 'default')
Inventory:AccessSize
Open an inventory with custom dimensions.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Unique inventory identifier |
width |
int | Grid width |
height |
int | Grid height |
weight |
float | Max weight capacity |
type |
string | Display type |
-- Client-side
TriggerServerEvent('Inventory:AccessSize', 'custom-inv', 10, 5, 50000, 'Custom Inventory')
Inventory:AccessSpecial
Open an inventory with special generation behavior.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Unique inventory identifier |
type |
string | Inventory size preset |
special |
string | Generation type (from generation.json) |
-- Client-side
TriggerServerEvent('Inventory:AccessSpecial', 'loot-' .. math.random(1000), 'default', 'trash-can')
Inventory:AccessSizeSpecial
Open an inventory with custom dimensions and generation.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Unique inventory identifier |
width |
int | Grid width |
height |
int | Grid height |
weight |
float | Max weight capacity |
type |
string | Display type |
special |
string | Generation type |
-- Client-side
TriggerServerEvent('Inventory:AccessSizeSpecial', 'loot-rare', 8, 6, 30000, 'Rare Loot', 'rare-loot')
Inventory:AccessSlotInventory
Open a slot-based inventory.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Slot inventory identifier |
type |
string | Slot inventory type (from slotinventories.json) |
-- Client-side
TriggerServerEvent('Inventory:AccessSlotInventory', 'player-' .. charId, 'Player')
Inventory:AccessSlotForce
Force open a slot inventory on a player (admin use).
| Parameter | Type | Description |
|---|---|---|
playerId |
int | Target player server ID |
inventoryId |
string | Slot inventory to open |
-- Server-side only
TriggerEvent('Inventory:AccessSlotForce', targetPlayerId, 'player-' .. targetCharId)
Inventory:AccessItem
Open an item's interior inventory.
| Parameter | Type | Description |
|---|---|---|
itemId |
string | Unique item ID |
inventoryId |
string | Container inventory ID |
slot |
string | Slot containing item (or empty) |
-- Client-side
TriggerServerEvent('Inventory:AccessItem', itemId, 'playerinventory-' .. charId, '')
Inventory:AccessPlayer
Request access to another player's inventory.
| Parameter | Type | Description |
|---|---|---|
targetId |
int | Target player server ID |
-- Client-side
TriggerServerEvent('Inventory:AccessPlayer', GetPlayerServerId(closestPlayer))
Inventory:AccessMe
Grant inventory access to a requesting player.
| Parameter | Type | Description |
|---|---|---|
requesterId |
int | Requesting player server ID |
charId |
string | Your character ID |
-- Client-side (response to access request)
TriggerServerEvent('Inventory:AccessMe', requesterId, charId)
Inventory Management Events
Inventory:Create
Create a new inventory with default dimensions.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Unique inventory identifier |
type |
string | Inventory size preset |
-- Server-side
TriggerEvent('Inventory:Create', 'house-storage-123', 'default')
Inventory:CreateAdvanced
Create an inventory with custom parameters.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Unique inventory identifier |
type |
string | Display name |
width |
int | Grid width |
height |
int | Grid height |
weight |
float | Max weight |
blacklist |
table | Blocked item types |
whitelist |
table | Allowed item types |
-- Server-side
TriggerEvent('Inventory:CreateAdvanced', 'fridge-123', 'Fridge', 6, 4, 20000, {}, {'food', 'drink'})
Inventory:CreateSlot
Create a new slot-based inventory.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Unique inventory identifier |
type |
string | Slot inventory type |
-- Server-side
TriggerEvent('Inventory:CreateSlot', 'player-' .. charId, 'Player')
Inventory:Generate
Generate random items in an inventory.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Target inventory |
special |
string | Generation type |
-- Server-side
TriggerEvent('Inventory:Generate', 'loot-box-' .. boxId, 'rare-loot')
Inventory:Rename
Change an inventory's display name.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Target inventory |
displayName |
string | New display name |
-- Server-side
TriggerEvent('Inventory:Rename', 'stash-123', 'My Personal Stash')
Inventory:MoveSlotIntoInventory
Move all items from a slot inventory into a regular inventory.
| Parameter | Type | Description |
|---|---|---|
slotInventoryId |
string | Source slot inventory |
inventoryId |
string | Target inventory |
type |
string | Target inventory type |
-- Server-side
TriggerEvent('Inventory:MoveSlotIntoInventory', 'vehicle-ABC123', 'impound-lot', 'default')
Inventory:MoveSlotToSlot
Move an item from one slot to another.
| Parameter | Type | Description |
|---|---|---|
fromInventory |
string | Source slot inventory |
fromSlot |
string | Source slot |
toInventory |
string | Target slot inventory |
toSlot |
string | Target slot |
-- Server-side
TriggerEvent('Inventory:MoveSlotToSlot', 'player-123', 'hand', 'player-123', 'holster')
Item Events
Inventory:DropItem
Drop an item on the ground.
| Parameter | Type | Description |
|---|---|---|
itemId |
string | Item to drop |
placement |
vector4 | Position and heading |
inventoryId |
string | Source inventory |
slot |
string | Source slot (or empty) |
charId |
string | Character ID |
force |
bool | Force drop |
-- Client-side
local coords = GetEntityCoords(PlayerPedId())
TriggerServerEvent('Inventory:DropItem', itemId, vector4(coords.x, coords.y, coords.z - 1.0, 0.0), inventoryId, '', charId, false)
Inventory:UseItem
Use/consume an item.
| Parameter | Type | Description |
|---|---|---|
itemId |
string | Item to use |
inventoryId |
string | Containing inventory |
slot |
string | Containing slot (or empty) |
-- Client-side
TriggerServerEvent('Inventory:UseItem', itemId, inventoryId, slot)
Inventory:UseItemSafe
Use an item with safety validation.
| Parameter | Type | Description |
|---|---|---|
itemId |
string | Item to use |
inventoryId |
string | Containing inventory |
slot |
string | Containing slot |
safeSlot |
string | Safety slot reference |
-- Client-side
TriggerServerEvent('Inventory:UseItemSafe', itemId, inventoryId, slot, safeSlot)
Inventory:LockItem
Lock an item to prevent movement.
| Parameter | Type | Description |
|---|---|---|
itemId |
string | Item to lock |
inventoryId |
string | Containing inventory |
slot |
string | Containing slot |
-- Client-side
TriggerServerEvent('Inventory:LockItem', itemId, inventoryId, slot)
Inventory:TryEquip
Attempt to equip an item.
| Parameter | Type | Description |
|---|---|---|
itemId |
string | Item to equip |
inventoryId |
string | Source inventory |
slot |
string | Source slot |
targetSlot |
string | Target equipment slot |
-- Client-side
TriggerServerEvent('Inventory:TryEquip', itemId, inventoryId, slot, 'hand')
Inventory:InstallItem
Install an item (attachment, upgrade).
| Parameter | Type | Description |
|---|---|---|
itemId |
string | Item to install |
inventoryId |
string | Target inventory |
slot |
string | Target slot |
-- Client-side
TriggerServerEvent('Inventory:InstallItem', attachmentId, weaponInventoryId, 'suppressor')
Ground Item Events
Inventory:GroundAccess
Access a dropped item's inventory.
| Parameter | Type | Description |
|---|---|---|
itemId |
string | Ground item ID |
-- Client-side
TriggerServerEvent('Inventory:GroundAccess', groundItemId)
Inventory:GroundPickup
Pick up a dropped item.
| Parameter | Type | Description |
|---|---|---|
itemId |
string | Ground item ID |
playerInventory |
string | Your inventory ID |
-- Client-side
TriggerServerEvent('Inventory:GroundPickup', groundItemId, 'playerinventory-' .. charId)
Inventory:RequestPlacedItems
Request all dropped items near you.
-- Client-side
TriggerServerEvent('Inventory:RequestPlacedItems')
Inventory:RequestPlacedItemsAtCoordinates
Request dropped items within a radius.
| Parameter | Type | Description |
|---|---|---|
x |
float | X coordinate |
y |
float | Y coordinate |
z |
float | Z coordinate |
radius |
float | Search radius |
-- Client-side
local coords = GetEntityCoords(PlayerPedId())
TriggerServerEvent('Inventory:RequestPlacedItemsAtCoordinates', coords.x, coords.y, coords.z, 10.0)
Inventory:ClearRadiusOfItems
Remove all dropped items in a radius (admin).
| Parameter | Type | Description |
|---|---|---|
x |
float | X coordinate |
y |
float | Y coordinate |
z |
float | Z coordinate |
radius |
float | Clear radius |
-- Server-side
TriggerEvent('Inventory:ClearRadiusOfItems', x, y, z, 50.0)
Proximity Events
Inventory:AddProximityInventory
Create an inventory visible within a radius.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Unique inventory ID |
x |
float | X coordinate |
y |
float | Y coordinate |
z |
float | Z coordinate |
radius |
float | Visibility radius |
name |
string | Display name |
-- Server-side
TriggerEvent('Inventory:AddProximityInventory', 'dumpster-' .. dumpsterId, x, y, z, 2.0, 'Dumpster')
Inventory:RemoveProximityInventory
Remove a proximity inventory.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Inventory to remove |
-- Server-side
TriggerEvent('Inventory:RemoveProximityInventory', 'dumpster-' .. dumpsterId)
Network Object Events
Inventory:AddNetworkObject
Link an inventory to a network object.
| Parameter | Type | Description |
|---|---|---|
networkId |
int | Network object ID |
inventoryId |
string | Inventory to link |
-- Server-side
local netId = NetworkGetNetworkIdFromEntity(object)
TriggerEvent('Inventory:AddNetworkObject', netId, 'object-inv-' .. netId)
Inventory:RemoveNetworkObject
Unlink an inventory from a network object.
| Parameter | Type | Description |
|---|---|---|
networkId |
int | Network object ID |
-- Server-side
TriggerEvent('Inventory:RemoveNetworkObject', netId)
Weapon Events
Inventory:TryReload
Reload the equipped weapon.
| Parameter | Type | Description |
|---|---|---|
charId |
string | Character ID |
-- Client-side
TriggerServerEvent('Inventory:TryReload', charId)
Inventory:UnloadAmmo
Unload ammunition from a weapon.
| Parameter | Type | Description |
|---|---|---|
itemId |
string | Weapon item ID |
charId |
string | Character ID |
-- Client-side
TriggerServerEvent('Inventory:UnloadAmmo', weaponItemId, charId)
Inventory:ShotFired
Notify that a shot was fired (ammo tracking).
| Parameter | Type | Description |
|---|---|---|
charId |
string | Character ID |
-- Client-side
TriggerServerEvent('Inventory:ShotFired', charId)
Admin Events
Inventory:CreateAdminInventory
Create an inventory with admin options.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Inventory ID |
type |
string | Inventory type |
skip |
int | Skip database save (1 = skip) |
-- Server-side
TriggerEvent('Inventory:CreateAdminInventory', source, 'admin-view', 'default', 0)
Inventory:CreateEventInventory
Create an inventory that triggers events on click.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Inventory ID |
clickEvent |
string | Event to trigger |
type |
string | Inventory type |
-- Server-side
TriggerEvent('Inventory:CreateEventInventory', source, 'shop-' .. shopId, 'shop:buyItem', 'default') Server Exports
These exports are available on the server-side. Call them using exports['inventory']:ExportName().
All exports are asynchronous and return promises. Use Citizen.Await() or callbacks.
Player Operations
AddItemToPlayer
Add an item to a player's inventory. Drops on ground if inventory is full.
| Parameter | Type | Description |
|---|---|---|
name |
string | Item type name |
player |
int | Player server ID |
charId |
string | Character identifier |
count |
int | Quantity to add |
Returns: string - Item ID if added, nil if failed
local itemId = exports['inventory']:AddItemToPlayer('water', source, charId, 5)
if itemId then
print('Added water with ID: ' .. itemId)
end
RemoveItemFromPlayer
Remove items by type from a player's inventory.
| Parameter | Type | Description |
|---|---|---|
name |
string | Item type name |
charId |
string | Character identifier |
count |
int | Quantity to remove |
Returns: bool - Success status
local success = exports['inventory']:RemoveItemFromPlayer('water', charId, 3)
RemoveItemFromPlayerByID
Remove a specific item instance from player's inventory.
| Parameter | Type | Description |
|---|---|---|
itemId |
string | Unique item ID |
charId |
string | Character identifier |
Returns: bool - Success status
local success = exports['inventory']:RemoveItemFromPlayerByID(itemId, charId)
Inventory Operations
AddItem / InventoryAddItem
Add an item to any inventory.
| Parameter | Type | Description |
|---|---|---|
name |
string | Item type name |
inventoryId |
string | Target inventory ID |
Returns: string - Item ID if added
local itemId = exports['inventory']:AddItem('bandage', 'stash-123')
-- or
local itemId = exports['inventory']:InventoryAddItem('bandage', 'stash-123')
AddItemStack / InventoryAddItemStack
Add a stack of items to an inventory.
| Parameter | Type | Description |
|---|---|---|
name |
string | Item type name |
inventoryId |
string | Target inventory ID |
count |
int | Stack quantity |
Returns: bool - Success status
local success = exports['inventory']:AddItemStack('ammo_pistol', 'stash-123', 30)
RemoveItem / InventoryRemoveItem
Remove items by type from an inventory.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Source inventory ID |
type |
string | Item type name |
count |
int | Quantity to remove |
Returns: bool - Success status
local success = exports['inventory']:RemoveItem('stash-123', 'water', 2)
RemoveItemByID / InventoryRemoveItemByID
Remove a specific item instance from an inventory.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Source inventory ID |
itemId |
string | Unique item ID |
all |
bool | Remove entire stack |
Returns: bool - Success status
local success = exports['inventory']:RemoveItemByID('stash-123', itemId, true)
HasItem / InventoryHasItem
Check if an inventory contains an item type.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Inventory to check |
type |
string | Item type name |
Returns: bool - Whether item exists
local hasWater = exports['inventory']:HasItem('playerinventory-' .. charId, 'water')
HasItemByID / InventoryHasItemByID
Check if an inventory contains a specific item instance.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Inventory to check |
itemId |
string | Unique item ID |
Returns: bool - Whether item exists
local exists = exports['inventory']:HasItemByID('stash-123', itemId)
ItemCount / InventoryItemCount
Get the count of an item type in an inventory.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Inventory to check |
type |
string | Item type name |
Returns: int - Item count
local waterCount = exports['inventory']:ItemCount('playerinventory-' .. charId, 'water')
print('Player has ' .. waterCount .. ' water')
GetItem / InventoryGetItem
Get an item by type from an inventory.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Inventory to search |
type |
string | Item type name |
Returns: string - Item ID if found
local itemId = exports['inventory']:GetItem('stash-123', 'pistol')
CanFit / InventoryCanFit
Check if an item can fit in an inventory.
| Parameter | Type | Description |
|---|---|---|
name |
string | Item type name |
inventoryId |
string | Target inventory ID |
Returns: bool - Whether item fits
local canFit = exports['inventory']:CanFit('backpack', 'playerinventory-' .. charId)
if canFit then
exports['inventory']:AddItem('backpack', 'playerinventory-' .. charId)
end
GetWeight / InventoryGetWeight
Get the total weight of an inventory.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Inventory to check |
Returns: float - Total weight in grams
local weight = exports['inventory']:GetWeight('playerinventory-' .. charId)
print('Carrying ' .. weight .. 'g')
GetInventory
Get the full inventory data as JSON.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Inventory to get |
Returns: string - JSON inventory data
local invJson = exports['inventory']:GetInventory('stash-123')
local inv = json.decode(invJson)
DeleteInventory
Permanently delete an inventory.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Inventory to delete |
Returns: bool - Success status
local success = exports['inventory']:DeleteInventory('stash-old')
DoesInventoryExist
Check if an inventory exists.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Inventory to check |
Returns: bool - Whether inventory exists
local exists = exports['inventory']:DoesInventoryExist('house-storage-123')
if not exists then
TriggerEvent('Inventory:Create', 'house-storage-123', 'default')
end
GetAllItemIDsInInventoryByType
Get all item IDs of a specific type in an inventory.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Inventory to search |
type |
string | Item type name |
Returns: string - JSON array of item IDs
local idsJson = exports['inventory']:GetAllItemIDsInInventoryByType('stash-123', 'weapon')
local ids = json.decode(idsJson)
for _, id in ipairs(ids) do
print('Found weapon: ' .. id)
end
Item Metadata
GetItemExtraData
Get custom metadata from an item.
| Parameter | Type | Description |
|---|---|---|
itemId |
string | Unique item ID |
dataKey |
string | Metadata key |
inventoryId |
string | Containing inventory |
slot |
string | Containing slot (or empty) |
Returns: any - Metadata value
local serialNumber = exports['inventory']:GetItemExtraData(weaponId, 'serial', inventoryId, '')
GetAllItemExtraData
Get all custom metadata from an item.
| Parameter | Type | Description |
|---|---|---|
itemId |
string | Unique item ID |
inventoryId |
string | Containing inventory |
slot |
string | Containing slot (or empty) |
Returns: table - All metadata
local extraData = exports['inventory']:GetAllItemExtraData(itemId, inventoryId, '')
print(json.encode(extraData))
SetItemExtraData
Set custom metadata on an item.
| Parameter | Type | Description |
|---|---|---|
itemId |
string | Unique item ID |
dataKey |
string | Metadata key |
dataValue |
any | Metadata value |
inventoryId |
string | Containing inventory |
slot |
string | Containing slot (or empty) |
Returns: bool - Success status
exports['inventory']:SetItemExtraData(weaponId, 'serial', 'ABC123', inventoryId, '')
exports['inventory']:SetItemExtraData(phoneId, 'contacts', {}, inventoryId, '')
GetFriendlyName
Get the display name for an item type.
| Parameter | Type | Description |
|---|---|---|
type |
string | Item type name |
Returns: string - Friendly display name
local name = exports['inventory']:GetFriendlyName('weapon_pistol')
print('Item name: ' .. name) -- "Pistol"
GetItemIcon
Get the icon path for an item type.
| Parameter | Type | Description |
|---|---|---|
type |
string | Item type name |
Returns: string - Icon path
local icon = exports['inventory']:GetItemIcon('water')
GetItemProp
Get prop information for an item type.
| Parameter | Type | Description |
|---|---|---|
type |
string | Item type name |
Returns: string - Prop model name
local prop = exports['inventory']:GetItemProp('flashlight')
GetItemType
Get the type of a specific item instance.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Containing inventory |
itemId |
string | Unique item ID |
Returns: string - Item type name
local type = exports['inventory']:GetItemType('stash-123', itemId)
GetItemTypes
Get all item types.
| Parameter | Type | Description |
|---|---|---|
type |
string | Filter by type (or empty) |
Returns: string - JSON array of types
local typesJson = exports['inventory']:GetItemTypes('weapon')
local types = json.decode(typesJson)
World Items
CreateWorldItem / InventoryCreateWorldItem
Spawn an item on the ground.
| Parameter | Type | Description |
|---|---|---|
item |
string | Item type name |
x |
float | X coordinate |
y |
float | Y coordinate |
z |
float | Z coordinate |
heading |
float | Heading angle |
count |
int | Stack quantity |
placeProperly |
bool | Use proper placement |
Returns: string - World item ID
local worldItemId = exports['inventory']:CreateWorldItem('water', x, y, z, 0.0, 1, true)
RemoveWorldItem / InventoryRemoveWorldItem
Remove a dropped item by ID.
| Parameter | Type | Description |
|---|---|---|
itemId |
string | World item ID |
Returns: bool - Success status
local success = exports['inventory']:RemoveWorldItem(worldItemId)
RemoveWorldItemByProp / InventoryRemoveWorldItemByProp
Remove dropped items at coordinates by prop model.
| Parameter | Type | Description |
|---|---|---|
x |
float | X coordinate |
y |
float | Y coordinate |
z |
float | Z coordinate |
prop |
string | Prop model name |
Returns: bool - Success status
exports['inventory']:RemoveWorldItemByProp(x, y, z, 'prop_cs_cardbox_01')
RemoveWorldItemByType / InventoryRemoveWorldItemByType
Remove dropped items at coordinates by item type.
| Parameter | Type | Description |
|---|---|---|
x |
float | X coordinate |
y |
float | Y coordinate |
z |
float | Z coordinate |
type |
string | Item type name |
Returns: bool - Success status
exports['inventory']:RemoveWorldItemByType(x, y, z, 'water')
IsItemInRadius
Check if an item type exists within a radius.
| Parameter | Type | Description |
|---|---|---|
x |
float | X coordinate |
y |
float | Y coordinate |
z |
float | Z coordinate |
radius |
float | Search radius |
type |
string | Item type name |
Returns: bool - Whether item found
local hasWeapon = exports['inventory']:IsItemInRadius(x, y, z, 5.0, 'weapon_pistol')
GetWorldItemCoords
Get the coordinates of a dropped item.
| Parameter | Type | Description |
|---|---|---|
itemId |
string | World item ID |
Returns: vector4 - Position and heading
local coords = exports['inventory']:GetWorldItemCoords(worldItemId)
Slot Inventory Operations
SlotInventoryAddItem
Add an item to the first available slot.
| Parameter | Type | Description |
|---|---|---|
name |
string | Item type name |
inventoryId |
string | Slot inventory ID |
count |
int | Quantity |
Returns: string - Item ID if added
local itemId = exports['inventory']:SlotInventoryAddItem('hat', 'player-' .. charId, 1)
SlotInventoryAddItemPreferSlot
Add an item, preferring a specific slot.
| Parameter | Type | Description |
|---|---|---|
name |
string | Item type name |
inventoryId |
string | Slot inventory ID |
slot |
string | Preferred slot |
Returns: string - Item ID if added
local itemId = exports['inventory']:SlotInventoryAddItemPreferSlot('glasses', 'player-' .. charId, 'glasses')
SlotInventoryAddItemToSlot
Add an item to a specific slot.
| Parameter | Type | Description |
|---|---|---|
name |
string | Item type name |
inventoryId |
string | Slot inventory ID |
slot |
string | Target slot |
Returns: string - Item ID if added
local itemId = exports['inventory']:SlotInventoryAddItemToSlot('weapon_pistol', 'player-' .. charId, 'holster')
SlotInventoryAddItemStack
Add a stack of items to a slot.
| Parameter | Type | Description |
|---|---|---|
name |
string | Item type name |
inventoryId |
string | Slot inventory ID |
count |
int | Stack quantity |
Returns: bool - Success status
exports['inventory']:SlotInventoryAddItemStack('ammo_pistol', weaponSlotInv, 30)
SlotInventoryRemoveItem
Remove items by type from a slot inventory.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Slot inventory ID |
type |
string | Item type name |
count |
int | Quantity to remove |
Returns: bool - Success status
exports['inventory']:SlotInventoryRemoveItem('player-' .. charId, 'hat', 1)
SlotInventoryRemoveItemFromSlot / RemoveItemFromSlot
Remove an item from a specific slot.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Slot inventory ID |
slot |
string | Slot to clear |
count |
int | Quantity to remove |
Returns: bool - Success status
exports['inventory']:SlotInventoryRemoveItemFromSlot('player-' .. charId, 'hat', 1)
SlotInventoryGetItemInSlot
Get the item in a specific slot.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Slot inventory ID |
slot |
string | Slot to check |
Returns: string - Item ID or nil
local itemId = exports['inventory']:SlotInventoryGetItemInSlot('player-' .. charId, 'hand')
SlotInventoryGetWeight
Get total weight of a slot inventory.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Slot inventory ID |
Returns: float - Total weight
local weight = exports['inventory']:SlotInventoryGetWeight('player-' .. charId)
SlotInventoryItemCount
Get count of an item type in a slot inventory.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Slot inventory ID |
type |
string | Item type name |
Returns: int - Item count
local count = exports['inventory']:SlotInventoryItemCount('player-' .. charId, 'ammo_pistol')
SlotInventoryCanFit
Check if an item can fit in a slot inventory.
| Parameter | Type | Description |
|---|---|---|
name |
string | Item type name |
inventoryId |
string | Slot inventory ID |
Returns: bool - Whether item fits
local canFit = exports['inventory']:SlotInventoryCanFit('backpack', 'player-' .. charId)
GetSlotInventory
Get full slot inventory data as JSON.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Slot inventory ID |
Returns: string - JSON slot inventory data
local invJson = exports['inventory']:GetSlotInventory('player-' .. charId)
local inv = json.decode(invJson)
DeleteSlotInventory
Permanently delete a slot inventory.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Slot inventory ID |
Returns: bool - Success status
exports['inventory']:DeleteSlotInventory('player-old-' .. charId)
DoesSlotInventoryExist
Check if a slot inventory exists.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Slot inventory ID |
Returns: bool - Whether exists
local exists = exports['inventory']:DoesSlotInventoryExist('player-' .. charId)
IsSlotInventoryEmpty
Check if a slot inventory has no items.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Slot inventory ID |
Returns: bool - Whether empty
local isEmpty = exports['inventory']:IsSlotInventoryEmpty('vehicle-' .. plate)
DoesSlotInventoryContainItem
Check if slot inventory contains an item type.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Slot inventory ID |
type |
string | Item type name |
climb |
bool | Check nested inventories |
Returns: bool - Whether item found
local hasWeapon = exports['inventory']:DoesSlotInventoryContainItem('player-' .. charId, 'weapon', true)
DoesSlotInventoryContainItemContentsOnly
Check slot inventory contents only (not nested).
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Slot inventory ID |
type |
string | Item type name |
Returns: bool - Whether item found
local hasDirect = exports['inventory']:DoesSlotInventoryContainItemContentsOnly('player-' .. charId, 'weapon')
GetAllItemCountsInSlotInventory
Get counts of all item types in slot inventory.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Slot inventory ID |
contentsOnly |
bool | Skip nested inventories |
countWithInterior |
bool | Count items with interiors |
Returns: string - JSON object of type:count
local countsJson = exports['inventory']:GetAllItemCountsInSlotInventory('player-' .. charId, false, true)
local counts = json.decode(countsJson)
GetAllItemIDsInSlotInventory
Get all item IDs in a slot inventory.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Slot inventory ID |
Returns: string - JSON array of item IDs
local idsJson = exports['inventory']:GetAllItemIDsInSlotInventory('player-' .. charId)
GetAllItemIDsInSlotInventoryByType
Get item IDs of a type in slot inventory.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Slot inventory ID |
type |
string | Item type name |
Returns: string - JSON array of item IDs
local idsJson = exports['inventory']:GetAllItemIDsInSlotInventoryByType('player-' .. charId, 'clothing')
GetItemInSlot
Get item ID from a specific slot.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Slot inventory ID |
slot |
string | Slot name |
Returns: string - Item ID or nil
local handItem = exports['inventory']:GetItemInSlot('player-' .. charId, 'hand')
GetItemTypeInSlot
Get item type from a specific slot.
| Parameter | Type | Description |
|---|---|---|
inventoryId |
string | Slot inventory ID |
slot |
string | Slot name |
Returns: string - Item type name or nil
local hatType = exports['inventory']:GetItemTypeInSlot('player-' .. charId, 'hat')
Utility
ClearPlayerHands
Remove item from player's hand slot.
| Parameter | Type | Description |
|---|---|---|
safeSlotInventory |
string | Player slot inventory ID |
exports['inventory']:ClearPlayerHands('player-' .. charId)
CreateSlotDrop
Create a dropped slot inventory.
| Parameter | Type | Description |
|---|---|---|
slot |
string | Slot type |
x |
float | X coordinate |
y |
float | Y coordinate |
z |
float | Z coordinate |
dropType |
string | Drop category |
Returns: string - Drop inventory ID
local dropId = exports['inventory']:CreateSlotDrop('backpack', x, y, z, 'bag') Examples
Complete working examples for common inventory integration patterns.
Basic Item Management
Adding Items to Player
-- Server-side
RegisterCommand('giveitem', function(source, args)
local itemName = args[1]
local count = tonumber(args[2]) or 1
local charId = GetCharIdentifier(source) -- Your identifier function
local itemId = exports['inventory']:AddItemToPlayer(itemName, source, charId, count)
if itemId then
TriggerClientEvent('chat:addMessage', source, {
args = { 'Received ' .. count .. 'x ' .. itemName }
})
else
TriggerClientEvent('chat:addMessage', source, {
args = { 'Could not add item - inventory may be full' }
})
end
end, false)
Removing Items from Player
-- Server-side
RegisterCommand('removeitem', function(source, args)
local itemName = args[1]
local count = tonumber(args[2]) or 1
local charId = GetCharIdentifier(source)
local success = exports['inventory']:RemoveItemFromPlayer(itemName, charId, count)
if success then
TriggerClientEvent('chat:addMessage', source, {
args = { 'Removed ' .. count .. 'x ' .. itemName }
})
else
TriggerClientEvent('chat:addMessage', source, {
args = { 'You don\'t have enough ' .. itemName }
})
end
end, false)
Checking Player Inventory
-- Server-side
function DoesPlayerHaveItem(source, itemName, count)
local charId = GetCharIdentifier(source)
local inventoryId = 'playerinventory-' .. charId
local itemCount = exports['inventory']:ItemCount(inventoryId, itemName)
return itemCount >= (count or 1)
end
-- Usage
RegisterCommand('checkitem', function(source, args)
local itemName = args[1]
if DoesPlayerHaveItem(source, itemName, 1) then
print('Player has ' .. itemName)
else
print('Player does not have ' .. itemName)
end
end, false)
Consumable Items
Food/Drink Item Definition
{
"Name": "water",
"FriendlyName": "Water Bottle",
"Icon": "img/items/water.png",
"ItemTypes": ["consumable", "drink"],
"Stackable": true,
"MaxStack": 10,
"RemoveOnUse": true,
"InitialWeight": 500,
"ExteriorDimensions": {
"Width": 1,
"Height": 1
},
"Events": {
"use-server": "consumption:drinkWater",
"use-client": "consumption:playDrinkAnimation"
}
}
Consumable Event Handlers
-- Server-side (server.lua)
RegisterNetEvent('consumption:drinkWater', function(source, itemId, inventoryId, slot)
local playerId = source
-- Add thirst (your system)
TriggerEvent('thirst:add', playerId, 25)
-- Notify player
TriggerClientEvent('Inventory:Notify', playerId, 'You drank water')
end)
-- Client-side (client.lua)
RegisterNetEvent('consumption:playDrinkAnimation', function(itemId)
local ped = PlayerPedId()
-- Request animation
RequestAnimDict('mp_player_intdrink')
while not HasAnimDictLoaded('mp_player_intdrink') do
Wait(10)
end
-- Play drinking animation
TaskPlayAnim(ped, 'mp_player_intdrink', 'loop_bottle', 8.0, 8.0, 2500, 49, 0, false, false, false)
Wait(2500)
ClearPedTasks(ped)
end)
Custom Stash System
Creating Player Stash
-- Server-side
local function GetPlayerStashId(source)
local charId = GetCharIdentifier(source)
return 'stash-' .. charId
end
RegisterNetEvent('stash:open', function()
local source = source
local stashId = GetPlayerStashId(source)
-- Create if doesn't exist
local exists = exports['inventory']:DoesInventoryExist(stashId)
if not exists then
TriggerEvent('Inventory:Create', stashId, 'default')
end
-- Open for player
TriggerClientEvent('openinventory', source, stashId, 'Personal Stash')
end)
House Stash with Custom Size
-- Server-side
RegisterNetEvent('house:openStash', function(houseId)
local source = source
local stashId = 'house-stash-' .. houseId
local exists = exports['inventory']:DoesInventoryExist(stashId)
if not exists then
-- Create with custom dimensions
TriggerEvent('Inventory:CreateAdvanced', stashId, 'House Storage', 12, 8, 100000, {}, {})
end
TriggerClientEvent('openinventory', source, stashId, 'House Storage')
end)
Vehicle Inventory
Client-Side Vehicle Check
-- Client-side
local function GetVehicleInventoryId(vehicle)
local plate = GetVehicleNumberPlateText(vehicle)
plate = string.gsub(plate, '%s+', '') -- Remove spaces
return 'vehicle-' .. plate
end
RegisterCommand('trunk', function()
local ped = PlayerPedId()
local coords = GetEntityCoords(ped)
local vehicle = GetClosestVehicle(coords.x, coords.y, coords.z, 5.0, 0, 71)
if vehicle == 0 then
TriggerEvent('chat:addMessage', { args = { 'No vehicle nearby' } })
return
end
-- Check if at trunk
local trunkCoords = GetOffsetFromEntityInWorldCoords(vehicle, 0.0, -2.5, 0.0)
local dist = #(coords - trunkCoords)
if dist > 2.0 then
TriggerEvent('chat:addMessage', { args = { 'Go to the trunk' } })
return
end
local inventoryId = GetVehicleInventoryId(vehicle)
TriggerServerEvent('Inventory:Access', inventoryId, 'vehicle-trunk')
end, false)
Server-Side Vehicle Inventory Creation
-- Server-side
RegisterNetEvent('Inventory:Access', function(inventoryId, type)
local source = source
-- Auto-create vehicle inventories
if string.find(inventoryId, 'vehicle-') then
local exists = exports['inventory']:DoesInventoryExist(inventoryId)
if not exists then
TriggerEvent('Inventory:Create', inventoryId, type)
end
end
end)
Shop System
Shop Item Definition
{
"Name": "shop_water",
"FriendlyName": "Water Bottle ($5)",
"Icon": "img/items/water.png",
"ItemTypes": ["shop-item"],
"ExteriorDimensions": {
"Width": 1,
"Height": 1
},
"ExtraData": {
"price": 5,
"gives": "water"
}
}
Shop Implementation
-- Server-side
local shops = {
['shop-247-1'] = {
name = '24/7 Store',
items = { 'shop_water', 'shop_bread', 'shop_chips' }
}
}
RegisterNetEvent('shop:open', function(shopId)
local source = source
local shop = shops[shopId]
if not shop then return end
-- Create event inventory (triggers event on item click)
TriggerEvent('Inventory:CreateEventInventory', source, shopId, 'shop:buyItem', 'default')
-- Add shop items
for _, itemName in ipairs(shop.items) do
exports['inventory']:AddItem(itemName, shopId)
end
TriggerClientEvent('openinventory', source, shopId, shop.name)
end)
RegisterNetEvent('shop:buyItem', function(itemId, inventoryId)
local source = source
local charId = GetCharIdentifier(source)
-- Get item data
local extraData = exports['inventory']:GetAllItemExtraData(itemId, inventoryId, '')
local price = extraData.price or 0
local gives = extraData.gives
-- Check money (your money system)
local money = GetPlayerMoney(source)
if money < price then
TriggerClientEvent('Inventory:Notify', source, 'Not enough money!')
return
end
-- Remove money
RemovePlayerMoney(source, price)
-- Give item
exports['inventory']:AddItemToPlayer(gives, source, charId, 1)
TriggerClientEvent('Inventory:Notify', source, 'Purchased for $' .. price)
end)
Crafting System
Crafting Recipe
-- Server-side
local recipes = {
['medkit'] = {
result = 'medkit',
resultCount = 1,
ingredients = {
{ item = 'bandage', count = 3 },
{ item = 'painkillers', count = 2 }
}
}
}
RegisterNetEvent('crafting:craft', function(recipeName)
local source = source
local charId = GetCharIdentifier(source)
local recipe = recipes[recipeName]
if not recipe then return end
-- Check ingredients
local inventoryId = 'playerinventory-' .. charId
for _, ingredient in ipairs(recipe.ingredients) do
local count = exports['inventory']:ItemCount(inventoryId, ingredient.item)
if count < ingredient.count then
TriggerClientEvent('Inventory:Notify', source, 'Missing: ' .. ingredient.item)
return
end
end
-- Check if result fits
local canFit = exports['inventory']:CanFit(recipe.result, inventoryId)
if not canFit then
TriggerClientEvent('Inventory:Notify', source, 'Inventory full!')
return
end
-- Remove ingredients
for _, ingredient in ipairs(recipe.ingredients) do
exports['inventory']:RemoveItemFromPlayer(ingredient.item, charId, ingredient.count)
end
-- Add result
exports['inventory']:AddItemToPlayer(recipe.result, source, charId, recipe.resultCount)
TriggerClientEvent('Inventory:Notify', source, 'Crafted: ' .. recipe.result)
end)
Weapon with Serial Number
Creating Weapon with Metadata
-- Server-side
RegisterNetEvent('weapons:giveWeapon', function(weaponType)
local source = source
local charId = GetCharIdentifier(source)
-- Add weapon
local itemId = exports['inventory']:AddItemToPlayer(weaponType, source, charId, 1)
if itemId then
-- Generate serial number
local serial = string.upper(string.format('%s%d%s%d',
string.char(math.random(65, 90)),
math.random(100, 999),
string.char(math.random(65, 90)),
math.random(100, 999)
))
-- Set serial on weapon
exports['inventory']:SetItemExtraData(itemId, 'serial', serial, 'playerinventory-' .. charId, '')
TriggerClientEvent('Inventory:Notify', source, 'Received weapon (S/N: ' .. serial .. ')')
end
end)
Checking Weapon Serial
-- Server-side
RegisterCommand('checkserial', function(source, args)
local charId = GetCharIdentifier(source)
local slotInventory = 'player-' .. charId
-- Get item in hand
local handItem = exports['inventory']:GetItemInSlot(slotInventory, 'hand')
if not handItem then
TriggerClientEvent('chat:addMessage', source, { args = { 'Nothing in hand' } })
return
end
local serial = exports['inventory']:GetItemExtraData(handItem, 'serial', slotInventory, 'hand')
if serial then
TriggerClientEvent('chat:addMessage', source, { args = { 'Serial: ' .. serial } })
else
TriggerClientEvent('chat:addMessage', source, { args = { 'Item has no serial number' } })
end
end, false)
Clothing Automation
Apply Clothing on Equip
-- Server-side event handler for clothing equip
RegisterNetEvent('clothing:equipped', function(source, itemId, inventoryId, slot)
local charId = GetCharIdentifier(source)
-- Get clothing data from item
local extraData = exports['inventory']:GetAllItemExtraData(itemId, inventoryId, slot)
local component = extraData.component
local drawable = extraData.drawable
local texture = extraData.texture or 0
if component then
-- Apply clothing to player
TriggerClientEvent('Clothing:LoadComponent', source, component, drawable, texture, nil, nil)
end
end)
Clothing Item Definition
{
"Name": "jacket_leather",
"FriendlyName": "Leather Jacket",
"Icon": "img/clothing/jacket_leather.png",
"ItemTypes": ["clothing", "torso"],
"Stackable": false,
"InitialWeight": 800,
"ExteriorDimensions": {
"Width": 2,
"Height": 2
},
"Events": {
"equip-server": "clothing:equipped",
"deequip-server": "clothing:unequipped"
},
"ExtraData": {
"component": 11,
"drawable": 24,
"texture": 0
}
}
Money Handling
Money Item Definition
{
"Name": "cash",
"FriendlyName": "Cash",
"Icon": "img/items/cash.png",
"ItemTypes": ["money", "valuable"],
"Stackable": true,
"MaxStack": 1000000,
"InitialWeight": 1,
"ExteriorDimensions": {
"Width": 1,
"Height": 1
}
}
Money Functions
-- Server-side
function GiveMoney(source, amount)
local charId = GetCharIdentifier(source)
exports['inventory']:AddItemStack('cash', 'playerinventory-' .. charId, amount)
end
function TakeMoney(source, amount)
local charId = GetCharIdentifier(source)
local inventoryId = 'playerinventory-' .. charId
local currentMoney = exports['inventory']:ItemCount(inventoryId, 'cash')
if currentMoney < amount then
return false
end
return exports['inventory']:RemoveItem(inventoryId, 'cash', amount)
end
function GetMoney(source)
local charId = GetCharIdentifier(source)
return exports['inventory']:ItemCount('playerinventory-' .. charId, 'cash')
end
Proximity Inventory (Dumpster)
-- Server-side
local dumpsters = {
{ x = 123.4, y = 456.7, z = 32.1 },
{ x = 234.5, y = 567.8, z = 33.2 }
}
AddEventHandler('onResourceStart', function(resourceName)
if resourceName ~= GetCurrentResourceName() then return end
for i, dumpster in ipairs(dumpsters) do
local inventoryId = 'dumpster-' .. i
-- Create proximity inventory
TriggerEvent('Inventory:AddProximityInventory',
inventoryId,
dumpster.x,
dumpster.y,
dumpster.z,
2.0,
'Dumpster'
)
-- Generate random loot
TriggerEvent('Inventory:Generate', inventoryId, 'trash-can')
end
end)