AddItemToSlot
function WIS.AddItemToSlot(slotIndex, itemData, ply, up)
Adds an item to a specified slot in the player's inventory. This function is key for directly placing items into a specific inventory slot, often used in conjunction with FindEmptySlot.
Parameters
Name | Type | Description |
---|---|---|
ply | Entity | The player entity whose inventory is being modified. |
slotIndex | integer | The index of the first empty slot, or nil if the inventory is full. |
itemData | table | The data of the item to be added to the inventory. |
up | boolean | A flag indicating whether to update the inventory UI. |
Use Case
This function is used for adding items directly to a specific slot in a player's inventory. It's useful in scenarios where the specific placement of items is important, such as when organizing inventory or moving items between slots.
Example
local player = Entity(1)
local slotIndex = 2 -- Assuming slot 2 is empty
local itemData = {/* item data */}
WIS.AddItemToSlot(player, slotIndex, itemData, false)