Integration
The script is fully functional as is, without requiring any modifications. However, for those who want to expand its capabilities, a complete integration allows for:
✅ Multiple Wrapping at Once With full integration, players can wrap multiple Gift Boxes simultaneously, improving efficiency and user experience.
✅ Seamless Inventory System Integration The script is designed to work with various inventory systems. By implementing additional metadata handling and export functions, it can seamlessly interact with different inventories, ensuring smooth item management.
🔹 Important Note:
These enhancements are optional and are only needed if you want to extend functionality.
This approach allows for greater adaptability while maintaining the script’s stability and usability in its default state.
📌 Integration Steps: To integrate, refer to the documentation of your inventory system. Pay close attention to the sections marked as "necessary for advanced integration" to ensure proper compatibility and implementation.
- Obtaining inventory
To ensure that the inventory is started and available you must go to the following path
Ks_Gift_Packaging/Framework/sh_Custom.lua:GetInventory(..)In the GetInventory(..)function, You should place your inventory, followed by the returns
You can copy the following code and replace 'other-inventory' with the name of your inventory resource
function GetInventory()
if GetResourceState('ox_inventory') == 'started' then
return 'ox_inventory', true
elseif GetResourceState('qb-inventory') == 'started' then
return 'qb-inventory', true
elseif GetResourceState('other-inventory') == 'started' then
return 'other-inventory', true -- return the inventory name and true as available
else
return nil, false
end
end- GivePlayerItem
source:
numberitemName:
stringitemCount:
numbermetadata:
tablenecessary for advanced integration
- RemovePlayerItem
source:
numberitemName:
stringitemCount:
numberslot:
numbernecessary for advanced integration
- UsePlayerItem
itemName:
stringuseFunction:
functionnecessary for advanced integration
Why is it necessary to inherit source and item in useFunction(source, item)?
source and item in useFunction(source, item)?Inheriting these parameters in useFunction(source, item) is essential for the following reasons:
The
sourceparameter represents the player's ID on the server, allowing us to target the correct player when executing actions.The
itemparameter contains essential details about the item in use. In this case, we need its metadata:item.metadata→ Additional data stored in the item, such as messages or unique attributes.
This ensures that item interactions work correctly and that any special properties assigned to an item can be properly accessed and used.
Where will we use the metadata of my object in use?
In this script, the metadata of the item is extracted and used in two main cases:
When a player uses a gift box (
ks.GiftBox)The script retrieves the item's metadata (
item.infooritem.metadata).It then triggers the event
'ks-Gifts:server:InternGiftBoxes', passing the player's ID (source), the item name (giftBox), and its metadata.This allows the server to process the gift box based on its specific properties.
When a player uses a gift card (
ks.GiftCard)
The metadata is retrieved the same way.
If the metadata contains a message, it is sent to the client using
'ks-Gifts:client:OpenCard'.If no message is found, the player receives a notification.
THESE FUNCTIONS ARE IN:
This metadata retrieval is not necessary for ox_inventory, unless the inventory system has a export to fetch the metadata of the item in use.
Last updated