The card item will always be sold with the same metadata.
No additional server-side logic is executed.
The metadata is assigned directly at the time of purchase.
2. Dynamic Metadata (server/editable.lua)
When metadata needs to be generated dynamically (for example, based on the player, identity, progress, or any other logic), you must use the following file:
This system allows you to intercept the item purchase and assign metadata just before the item is added to the player's inventory.
When to Use Dynamic Metadata
This method is recommended when:
The item requires unique data per player.
Metadata depends on external or runtime information.
Advanced logic is required.
Common examples include:
Phones with unique numbers.
Personal documents.
Keys, cards, credentials.
Items linked to player data.
Using LV.items:setMetadata
The server/editable.lua file provides a dedicated function to handle this behavior:
Function Parameters
The function receives the following parameters:
source: Player ID who is making the purchase.
itemName: Name of the item.
amount: Quantity purchased.
shopType: Type of shop where the item is bought.
metadata: Base metadata (if any) defined in shops.lua.
Important: The function must return a table containing the final metadata that will be assigned to the item.
Practical Example
In this example:
Every time a phone item is purchased.
The server dynamically generates its metadata.
The item is added to the inventory with personalized data.
This system can easily be extended to:
Generate unique serial numbers.
Read player-specific data.
Integrate with other scripts.
Metadata Priority
If an item does not have dynamic metadata, the metadata defined in shops.lua will be used.
If a function exists in server/editable.lua for that item, the returned metadata will replace or override the fixed metadata.
Recommendations
Use fixed metadata for simple and generic items.
Use dynamic metadata for unique items or items tied to server logic.