Skip to main content

What Are Meta Items?

Meta items are inventory items that store custom metadata (also called info 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 the decay property:
Never manually set lastUpdate unless you know what you’re doing! The system manages this automatically.

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 the info parameter:
Parameters:
  • source - Player server ID or stash identifier
  • item_name - Name of the item (from shared/items.lua)
  • amount - Quantity to add
  • slot - (optional) Specific slot number, or nil for auto-slot
  • info - The metadata table
  • reason - Reason for logging

Example: Simple Meta Item

Example: Money Clip (Real Framework Example)

The money_clip item stores cash amount in metadata:
Then when used:

Use Cases & Examples

Use Case 1: Crafted Items with Crafter Name

Track who crafted an item:
Now when players view the chair in their inventory, they can see who crafted it!

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:
Or through callbacks:

Modifying Existing Metadata

Method 1: SetItemData

Method 2: Remove and Re-Add

For more complex updates, remove and re-add the item:

Best Practices

Keep metadata small: Only store essential data. Large metadata increases database size and network traffic.
Never trust client data: Always validate metadata on server-side before accepting it.
Use consistent keys: Establish naming conventions for your metadata fields (e.g., always use craftedBy instead of mixing crafter, made_by, etc.)

✅ Good Practices

❌ Bad Practices

Performance Tips

  1. Limit metadata size: Keep under 1KB per item when possible
  2. Index frequently accessed fields: If you query specific metadata often, consider separate database tables
  3. Clean up old metadata: Periodically remove expired or unused metadata
  4. 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
Unique Items:
  • 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 the decay property automatically use metadata for quality tracking:
When added, the system automatically sets:
Over time, quality decreases based on the decay rate.
Items with 0% quality are automatically deleted when the inventory is loaded if delete = true!

Database Storage

Metadata is stored as JSON in the database:

Player Inventory

Result:

Stash Storage

Metadata is stored the same way for stashes.

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:
  1. Make the item unique = true in items.lua
  2. Ensure each item has different metadata
  3. Use a specific slot to prevent stacking

Error: Accessing Nil Metadata

Problem: Trying to access metadata that doesn’t exist
Solution: Always check if metadata exists:

Advanced: Custom Metadata Validation

Create a validation system for metadata:

Summary

Meta items provide powerful customization for inventory items:

Next Steps


Need more help? Join the RSG Framework Discord!