Skip to main content

addInventoryItem

xPlayer.addInventoryItem(item, count)

This function adds an inventory item.

Arguments

ArgumentData TypeOptionalDefault ValueExplanation
itemstringNo-Item name
countnumberNo-Count of item to add

!!! warning This function will not check if the player weight limit exceeds. Recommended to use in comibation with xPlayer.canCarryItem(item, count)

Example

if targetXPlayer.canCarryItem(itemName, itemCount) then
sourceXPlayer.removeInventoryItem(itemName, itemCount)
targetXPlayer.addInventoryItem(itemName, itemCount)
else
sourceXPlayer.showNotification('Target player could not hold all of that.')
end