What Are Meta Items?
Meta items are inventory items that store custom metadata (also calledinfo data) beyond the basic item properties. This metadata allows items to have unique characteristics, track additional information, or store custom values that make each item instance different.
Meta items enable dynamic gameplay features like: quality tracking, serial numbers, stored values, timestamps, player names, custom descriptions, and much more!
Understanding Item Metadata
Basic Item Structure
Every inventory item has standard properties:The info Field
The info field is a Lua table that can store any custom data you want:
The
info table is saved to the database and persists across server restarts. It’s stored as JSON in the database.Reserved Metadata Fields
Some metadata fields have special meaning in the RSG Framework:1. quality - Item Condition
Used by the decay system and weapons:- 100: Perfect condition
- 75-99: Good condition
- 50-74: Decent condition
- 25-49: Poor condition
- 0-24: Very poor condition
- 0: Item is destroyed (deleted on next inventory load)
2. lastUpdate - Decay Timestamp
Automatically set for items with thedecay property:
3. serie - Weapon Serial Number
Automatically generated for weapons:4. ammo - Weapon Ammunition
Current ammo count for weapons:Creating Items with Metadata
Method 1: AddItem with Info Parameter
The primary way to add metadata is through theinfo parameter:
source- Player server ID or stash identifieritem_name- Name of the item (from shared/items.lua)amount- Quantity to addslot- (optional) Specific slot number, or nil for auto-slotinfo- The metadata tablereason- Reason for logging
Example: Simple Meta Item
Example: Money Clip (Real Framework Example)
Themoney_clip item stores cash amount in metadata:
Use Cases & Examples
Use Case 1: Crafted Items with Crafter Name
Track who crafted an item:Use Case 2: Signed Documents
Create items that can be signed by players:Use Case 3: Timed Items / Expiration
Create items that expire after a certain time:Use Case 4: Container Items (Bags/Pouches)
Items that store other items:Use Case 5: Custom Description Items
Items with player-written descriptions:Use Case 6: Pet Items with Stats
Items representing pets with custom stats:Accessing Item Metadata
Server-Side Access
Get Item by Slot
Get Item by Name
Get All Items
Client-Side Access
Access metadata through PlayerData:Modifying Existing Metadata
Method 1: SetItemData
Method 2: Remove and Re-Add
For more complex updates, remove and re-add the item:Best Practices
Use consistent keys: Establish naming conventions for your metadata fields (e.g., always use
craftedBy instead of mixing crafter, made_by, etc.)Recommended Patterns
✅ Good Practices
❌ Bad Practices
Performance Tips
- Limit metadata size: Keep under 1KB per item when possible
- Index frequently accessed fields: If you query specific metadata often, consider separate database tables
- Clean up old metadata: Periodically remove expired or unused metadata
- Validate inputs: Check metadata before adding to prevent bad data
Unique Items vs Non-Unique Items
Understanding unique Property
Items can be marked as unique = true in shared/items.lua:
Stacking Behavior with Metadata
Non-Unique Items:- Only stack if metadata (
info) is identical - Different metadata = different stacks
- Always take individual slots
- Even if metadata is identical
When creating items with varying metadata, consider making them
unique = true to prevent unexpected stacking behavior.Decay System Integration
Items with thedecay property automatically use metadata for quality tracking:
Database Storage
Metadata is stored as JSON in the database:Player Inventory
Stash Storage
Common Errors & Troubleshooting
Error: Metadata Not Persisting
Problem: Item metadata disappears after server restart Cause: Item not saved properly Solution: Ensure the item is added correctly and the inventory is being saved:Error: Metadata Overwriting
Problem: Metadata gets overwritten when adding more of the same item Cause: Non-unique items with identical metadata stack together Solution: Either:- Make the item
unique = truein items.lua - Ensure each item has different metadata
- Use a specific slot to prevent stacking
Error: Accessing Nil Metadata
Problem: Trying to access metadata that doesn’t existAdvanced: Custom Metadata Validation
Create a validation system for metadata:Summary
Meta items provide powerful customization for inventory items:Next Steps
- Inventory Functions Reference - Complete list of all inventory exports
- Inventory Overview - Learn about the inventory system
- Weapons System - Weapon-specific metadata
Need more help? Join the RSG Framework Discord!