Introduction
The RSG Inventory system (rsg-inventory) is a comprehensive, weight-based inventory management system for RedM. It provides players with persistent inventory storage, item management, drops, stashes, and shops.
Version: 2.7.1
RSG Inventory is tightly integrated with rsg-core and rsg-weapons. All three work together to provide a complete item and weapon management system.
Core Features
π Weight & Slot System
- Weight-Based: Every item has a weight value, and players have a maximum carry capacity
- Slot-Based: Inventory is divided into slots (default: 25 slots)
- Configurable: Weight and slots can be adjusted per player via
PlayerData
π Inventory Types
The system supports multiple inventory types:- Player Inventory - Personal inventory for each player
- Stashes - Persistent storage locations (houses, gang storage, etc.)
- Drops - Ground items that can be picked up
- Shops - Vendor inventories for purchasing items
π Item Management
- Add/Remove Items: Server-side functions to modify inventory
- Item Transfer: Move items between inventories
- Item Info: Custom metadata for items (serial numbers, quality, etc.)
- Item Decay: Time-based item quality degradation
βοΈ Weapon Integration
- Weapons are stored as inventory items with type
'weapon' - Weapon-specific data (serial number, quality, ammo) stored in item
info - Seamless integration with rsg-weapons for durability and repair
How It Works
Item Structure
Every item in the inventory follows this structure:Weapon Item Structure
Weapons have additional information:Weight System
How Weight Works
- Items have a base
weightvalue (in grams) - Total weight =
item.weight * item.amount - Player carry capacity defined in
PlayerData.weight(default: 35000g = 35kg)
Example Weight Calculation
If a playerβs inventory is full (weight or slots), the system will automatically drop items on the ground instead of deleting them!
Slot System
How Slots Work
- Each inventory has a maximum number of slots
- Each item occupies one slot, regardless of quantity
- Exception: Unique items always take one slot each
Checking Slots
Item Decay System
The inventory supports time-based item quality degradation.How Decay Works
Items with thedecay property in shared/items.lua will lose quality over time:
- Quality: Ranges from 0-100
- Decay Rate: Time it takes for quality to reach 0
- Auto-Remove: Items at 0 quality are automatically removed on inventory load
Quality Effects
- 100-75%: Fresh/Good condition
- 74-50%: Decent condition
- 49-25%: Poor condition
- 24-1%: Very poor condition
- 0%: Item is destroyed/unusable
Ground Drops
How Drops Work
When items are dropped (or forced out of full inventory), they spawn on the ground as physical objects. Features:- Visual Object: A physical bag/satchel spawns at the location
- Persistence: Drops remain until picked up or server restart
- Network Synced: All players can see and interact with drops
- Weight Limit: Drops can hold multiple items up to weight limit
Drop Properties
Stashes
Stashes are persistent storage locations that can be accessed by multiple players (with proper permissions).Stash Types
- Player Stashes: Personal storage (houses, apartments)
- Job Stashes: Shared storage for job members
- Gang Stashes: Shared storage for gang members
- Public Stashes: Accessible by anyone
Stash Properties
Creating a Stash
Opening a Stash
Shops
The shop system allows players to purchase items from vendors.Shop Features
- Item Pricing: Each item has a defined price
- Stock Management: Items can have limited or unlimited stock
- Job Restrictions: Shops can be restricted to specific jobs
- Gang Restrictions: Shops can be restricted to specific gangs
Shop Structure
Shops are defined server-side and opened via exports:Database Storage
Player Inventory
Player inventories are stored in theplayers table:
inventory column stores a JSON array of items.
Stash Inventory
Stashes are stored in theinventories table:
Common Use Cases
Example 1: Give Player an Item
Example 2: Remove Item from Player
Example 3: Check Playerβs Items
Example 4: Create House Stash
Best Practices
Use reasons for logging: Always provide a reason parameter for auditing
Performance Considerations
- Batch operations when possible: Donβt add items in a loop, accumulate and add once
- Cache item checks: Donβt repeatedly call
HasItemfor the same item - Clean up stashes: Remove unused stashes to prevent database bloat
- Optimize drops: Limit the number of simultaneous drops on the server
Integration with Other Resources
Creating Useable Items
Items can be made useable in rsg-core:Inventory Events
Listen for inventory events in your resources:Troubleshooting
Inventory Not Saving
Check database connection
Check database connection
Ensure oxmysql is properly configured and connected
Check for errors
Check for errors
Look in server console for SQL errors or Lua errors
Verify item exists
Verify item exists
Make sure the item is defined in
rsg-core/shared/items.luaItems Disappearing
Common causes:- Item quality reached 0% (decay)
- Item not defined in shared items
- Database not saving properly
- Server crash before save
Inventory Full Errors
When inventory is full:- Items are automatically dropped on the ground
- Check ground drops near player
- Increase player weight/slots if needed
Next Steps
- Inventory Functions Reference - Complete list of all inventory exports
- Weapons System - Integration with rsg-weapons
- Item Configuration - How to define items in rsg-core
Need more help? Join the RSG Framework Discord!